|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Phonebook 2 contact view list box. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPbk2ContactViewListBox.h" |
|
21 |
|
22 // Phonebook 2 |
|
23 #include "MPbk2ContactViewListBoxModel.h" |
|
24 #include "CPbk2IconArray.h" |
|
25 #include "MPbk2NamesListState.h" |
|
26 #include "cpbk2contactviewdoublelistboxmodel.h" |
|
27 #include <CPbk2UIExtensionManager.h> |
|
28 #include <MPbk2UIExtensionIconSupport.h> |
|
29 #include <MPbk2UIExtensionFactory.h> |
|
30 #include <MPbk2ContactUiControlExtension.h> |
|
31 #include "CPbk2ListboxModelCmdDecorator.h" |
|
32 #include <CPbk2ContactIconsUtils.h> |
|
33 #include <Pbk2UIControls.hrh> |
|
34 |
|
35 // Virtual Phonebook |
|
36 #include <CVPbkContactManager.h> |
|
37 |
|
38 // System includes |
|
39 #include <barsread.h> |
|
40 #include <eikclbd.h> |
|
41 |
|
42 #include <aknappui.h> |
|
43 #include <aknviewappui.h> |
|
44 |
|
45 // Debugging headers |
|
46 #include <Pbk2Debug.h> |
|
47 #include <featmgr.h> |
|
48 |
|
49 #include <skinlayout.cdl.h> |
|
50 #include <aknlayoutscalable_apps.cdl.h> |
|
51 #include "cpbk2contactviewcustomlistboxitemdrawer.h" |
|
52 #include "cpbk2contactviewcustomlistboxdata.h" |
|
53 #include "CPbk2NamesListControl.h" |
|
54 |
|
55 |
|
56 /// Unnamed namespace for local definitions |
|
57 namespace { |
|
58 |
|
59 // LOCAL FUNCTIONS |
|
60 |
|
61 /** |
|
62 * Returns icon array from given list box. |
|
63 * |
|
64 * @param aListBox List box. |
|
65 * @return Icon array in Phonebook 2 format. |
|
66 */ |
|
67 inline CPbk2IconArray* IconArray( CEikColumnListBox& aListBox ) |
|
68 { |
|
69 return static_cast<CPbk2IconArray*>( |
|
70 aListBox.ItemDrawer()->ColumnData()->IconArray() ); |
|
71 } |
|
72 |
|
73 /** |
|
74 * Sets given icon array as given listbox's icon array. |
|
75 * |
|
76 * @param aListBox List box. |
|
77 * @param aIconArray Icon array. |
|
78 */ |
|
79 inline void SetIconArray( CEikColumnListBox& aListBox, |
|
80 CPbk2IconArray* aIconArray ) |
|
81 { |
|
82 aListBox.ItemDrawer()->ColumnData()->SetIconArray( aIconArray ); |
|
83 } |
|
84 |
|
85 #ifdef _DEBUG |
|
86 enum TPanicCode |
|
87 { |
|
88 EPanicPreCond_CreateListBoxModelL = 1 |
|
89 }; |
|
90 |
|
91 void Panic(TInt aReason) |
|
92 { |
|
93 _LIT(KPanicText, "CPbk2ContactViewListBox"); |
|
94 User::Panic(KPanicText, aReason); |
|
95 } |
|
96 #endif // _DEBUG |
|
97 } /// namespace |
|
98 |
|
99 // -------------------------------------------------------------------------- |
|
100 // CPbk2ContactViewListBox::CPbk2ContactViewListBox |
|
101 // -------------------------------------------------------------------------- |
|
102 // |
|
103 CPbk2ContactViewListBox::CPbk2ContactViewListBox |
|
104 ( CCoeControl& aContainer, |
|
105 MPbk2ContactUiControlExtension* aUiExtension, |
|
106 CPbk2PredictiveSearchFilter &aSearchFilter ) : |
|
107 iContainer(aContainer), |
|
108 iChangedIndexes( 1 ), // allocation granularity |
|
109 iUiExtension( aUiExtension ), |
|
110 iSearchFilter( aSearchFilter ) |
|
111 { |
|
112 } |
|
113 |
|
114 // -------------------------------------------------------------------------- |
|
115 // CPbk2ContactViewListBox::~CPbk2ContactViewListBox |
|
116 // -------------------------------------------------------------------------- |
|
117 // |
|
118 CPbk2ContactViewListBox::~CPbk2ContactViewListBox() |
|
119 { |
|
120 delete iListboxModelDecorator; |
|
121 delete iModel; |
|
122 FeatureManager::UnInitializeLib(); |
|
123 CCoeEnv::Static()->RemoveForegroundObserver( *this ); |
|
124 } |
|
125 |
|
126 // -------------------------------------------------------------------------- |
|
127 // CPbk2ContactViewListBox::ConstructL |
|
128 // -------------------------------------------------------------------------- |
|
129 // |
|
130 void CPbk2ContactViewListBox::ConstructL( |
|
131 CCoeControl& aContainer, TResourceReader& aResourceReader, |
|
132 const CVPbkContactManager& aManager, MVPbkContactViewBase& aView, |
|
133 MPbk2ContactNameFormatter& aNameFormatter, |
|
134 CPbk2StorePropertyArray& aStoreProperties ) |
|
135 { |
|
136 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
137 ("CPbk2ContactViewListBox::ConstructL")); |
|
138 |
|
139 FeatureManager::InitializeLibL(); |
|
140 |
|
141 // Preallocate space for the one required integer |
|
142 iChangedIndexes.AppendL( KErrNotFound ); |
|
143 |
|
144 // Read flags from resources |
|
145 iResourceData.iFlags = aResourceReader.ReadUint32(); // flags |
|
146 |
|
147 SetContainerWindowL( aContainer ); |
|
148 |
|
149 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
150 ("CPbk2ContactViewListBox::ConstructL about to resource construct")); |
|
151 |
|
152 // Let Avkon read it's share of the resources |
|
153 ConstructFromResourceL( aResourceReader ); |
|
154 |
|
155 // Remove the platform default "No data" text |
|
156 View()->SetListEmptyTextL( KNullDesC ); |
|
157 |
|
158 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
159 ("CPbk2ContactViewListBox::ConstructL about to create icon array")); |
|
160 |
|
161 CPbk2IconArray* iconArray = |
|
162 CPbk2ContactIconsUtils::CreateListboxIconArrayL( |
|
163 aResourceReader.ReadInt32()); |
|
164 |
|
165 SetIconArray( *this, iconArray ); |
|
166 |
|
167 iResourceData.iEmptyIconId = |
|
168 TPbk2IconId( aResourceReader ); // empty icon |
|
169 iResourceData.iDefaultIconId = |
|
170 TPbk2IconId( aResourceReader ); // default icon |
|
171 |
|
172 CreateScrollBarFrameL( ETrue ); |
|
173 ScrollBarFrame()->SetScrollBarVisibilityL( |
|
174 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
175 |
|
176 MakeVisible( EFalse ); |
|
177 |
|
178 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
179 ("CPbk2ContactViewListBox::ConstructL about to create model")); |
|
180 |
|
181 CreateListBoxModelL( aManager, aView, |
|
182 aNameFormatter, aStoreProperties ); |
|
183 |
|
184 CCoeEnv::Static()->AddForegroundObserverL( *this ); |
|
185 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
186 ("CPbk2ContactViewListBox::ConstructL end")); |
|
187 } |
|
188 |
|
189 // -------------------------------------------------------------------------- |
|
190 // CPbk2ContactViewListBox::NewL |
|
191 // -------------------------------------------------------------------------- |
|
192 // |
|
193 CPbk2ContactViewListBox* CPbk2ContactViewListBox::NewL( |
|
194 CCoeControl& aContainer, TResourceReader& aResourceReader, |
|
195 const CVPbkContactManager& aManager, MVPbkContactViewBase& aView, |
|
196 MPbk2ContactNameFormatter& aNameFormatter, |
|
197 CPbk2StorePropertyArray& aStoreProperties, |
|
198 MPbk2ContactUiControlExtension* aUiExtension, |
|
199 CPbk2PredictiveSearchFilter &aSearchFilter ) |
|
200 { |
|
201 CPbk2ContactViewListBox* self = |
|
202 new ( ELeave ) CPbk2ContactViewListBox( aContainer, aUiExtension, aSearchFilter ); |
|
203 CleanupStack::PushL( self ); |
|
204 self->ConstructL( aContainer, aResourceReader, aManager, |
|
205 aView, aNameFormatter, aStoreProperties ); |
|
206 CleanupStack::Pop( self ); |
|
207 return self; |
|
208 } |
|
209 |
|
210 // -------------------------------------------------------------------------- |
|
211 // CPbk2ContactViewListBox::NumberOfItems |
|
212 // -------------------------------------------------------------------------- |
|
213 // |
|
214 TInt CPbk2ContactViewListBox::NumberOfItems() const |
|
215 { |
|
216 TInt result = 0; |
|
217 if ( iListboxModelDecorator ) |
|
218 { |
|
219 result = iListboxModelDecorator->MdcaCount(); |
|
220 } |
|
221 return result; |
|
222 } |
|
223 |
|
224 // -------------------------------------------------------------------------- |
|
225 // CPbk2ContactViewListBox::ContactsMarked |
|
226 // -------------------------------------------------------------------------- |
|
227 // |
|
228 TBool CPbk2ContactViewListBox::ContactsMarked() const |
|
229 { |
|
230 const CListBoxView::CSelectionIndexArray* selections = |
|
231 View()->SelectionIndexes(); |
|
232 TBool notEmpty = selections && selections->Count() > 0; |
|
233 TBool containsContacts = EFalse; |
|
234 for (TInt n = 0; notEmpty && n < selections->Count() && !containsContacts; ++n ) |
|
235 { |
|
236 const TInt index = selections->At( n ); |
|
237 // The item is either a contact or a command. |
|
238 containsContacts = IsContact( index ); |
|
239 } |
|
240 return containsContacts; |
|
241 } |
|
242 |
|
243 // -------------------------------------------------------------------------- |
|
244 // CPbk2ContactViewListBox::HandleContactViewEventL |
|
245 // -------------------------------------------------------------------------- |
|
246 // |
|
247 void CPbk2ContactViewListBox::HandleEventL |
|
248 ( TInt aEvent, TInt aIndex ) |
|
249 { |
|
250 switch ( aEvent ) |
|
251 { |
|
252 case MPbk2NamesListState::EItemAdded: |
|
253 { |
|
254 iChangedIndexes[0] = aIndex; |
|
255 HandleItemAdditionL( iChangedIndexes ); |
|
256 break; |
|
257 } |
|
258 case MPbk2NamesListState::EItemRemoved: |
|
259 { |
|
260 // Deselect item |
|
261 CListBoxView& listBoxView = *View(); |
|
262 listBoxView.SetDisableRedraw( ETrue ); |
|
263 listBoxView.DeselectItem( aIndex ); |
|
264 listBoxView.SetDisableRedraw( EFalse ); |
|
265 |
|
266 TInt focusIndex = CurrentItemIndex(); |
|
267 TInt topIndex = TopItemIndex(); |
|
268 iChangedIndexes[0] = aIndex; |
|
269 HandleItemRemovalL( iChangedIndexes ); |
|
270 |
|
271 // The deduction of 1 is for adapting with the different bases |
|
272 const TInt lastIndex = Model()->NumberOfItems() - 1; |
|
273 if ( lastIndex == KErrNotFound ) |
|
274 { |
|
275 Reset(); |
|
276 } |
|
277 else |
|
278 { |
|
279 if ( aIndex < focusIndex ) |
|
280 { |
|
281 // If item was removed above focused item, maintain |
|
282 // focus by moving it up by one |
|
283 --focusIndex; |
|
284 } |
|
285 if ( focusIndex > lastIndex || focusIndex < 0 ) |
|
286 { |
|
287 focusIndex = lastIndex; |
|
288 } |
|
289 const TInt numVisibleItems = |
|
290 View()->NumberOfItemsThatFitInRect( |
|
291 View()->ViewRect() ); |
|
292 if ( topIndex + numVisibleItems > lastIndex ) |
|
293 { |
|
294 topIndex = Max( lastIndex - numVisibleItems + 1, 0 ); |
|
295 } |
|
296 if ( topIndex >= 0 ) |
|
297 { |
|
298 SetTopItemIndex( topIndex ); |
|
299 } |
|
300 if ( focusIndex >= 0 ) |
|
301 { |
|
302 SetCurrentItemIndex( focusIndex ); |
|
303 } |
|
304 } |
|
305 break; |
|
306 } |
|
307 default: |
|
308 { |
|
309 // Do nothing |
|
310 break; |
|
311 } |
|
312 } |
|
313 } |
|
314 |
|
315 // -------------------------------------------------------------------------- |
|
316 // CPbk2ContactViewListBox::FixTopItemIndex |
|
317 // -------------------------------------------------------------------------- |
|
318 // |
|
319 void CPbk2ContactViewListBox::FixTopItemIndex() |
|
320 { |
|
321 TInt index = TopItemIndex(); |
|
322 const TInt height = View()->NumberOfItemsThatFitInRect( |
|
323 View()->ViewRect() ); |
|
324 const TInt numItems = Model()->NumberOfItems(); |
|
325 if ( index + height > numItems ) |
|
326 { |
|
327 index += numItems - ( height + index ); |
|
328 if ( index < 0 ) |
|
329 { |
|
330 index = 0; |
|
331 } |
|
332 if ( index != TopItemIndex() ) |
|
333 { |
|
334 SetTopItemIndex( index ); |
|
335 } |
|
336 } |
|
337 } |
|
338 |
|
339 // -------------------------------------------------------------------------- |
|
340 // CPbk2ContactViewListBox::CheckFocusIndex |
|
341 // -------------------------------------------------------------------------- |
|
342 // |
|
343 void CPbk2ContactViewListBox::CheckFocusIndex() |
|
344 { |
|
345 if ( CurrentItemIndex() == KErrNotFound ) |
|
346 { |
|
347 SetCurrentItemIndex( 0 ); |
|
348 } |
|
349 } |
|
350 |
|
351 // -------------------------------------------------------------------------- |
|
352 // CPbk2ContactViewListBox::HandlePointerEventL |
|
353 // -------------------------------------------------------------------------- |
|
354 // |
|
355 void CPbk2ContactViewListBox::HandlePointerEventL |
|
356 ( const TPointerEvent& aPointerEvent ) |
|
357 { |
|
358 TInt oldIndex = CurrentItemIndex(); |
|
359 |
|
360 // Base class handles the pointer event |
|
361 CAknSingleGraphicStyleListBox::HandlePointerEventL( aPointerEvent ); |
|
362 |
|
363 switch( aPointerEvent.iType ) |
|
364 { |
|
365 case TPointerEvent::EButton1Down: |
|
366 { |
|
367 TInt pointedItemIndex; |
|
368 iFocusableContactPointed = View()->XYPosToItemIndex( |
|
369 aPointerEvent.iPosition, pointedItemIndex ); |
|
370 |
|
371 //no prior focus needed |
|
372 iFocusedContactPointed = iFocusableContactPointed; |
|
373 break; |
|
374 } |
|
375 default: |
|
376 { |
|
377 // Do nothing |
|
378 break; |
|
379 } |
|
380 }; |
|
381 } |
|
382 |
|
383 // -------------------------------------------------------------------------- |
|
384 // CPbk2ContactViewListBox::Flags |
|
385 // -------------------------------------------------------------------------- |
|
386 // |
|
387 TUint CPbk2ContactViewListBox::Flags() const |
|
388 { |
|
389 return iResourceData.iFlags; |
|
390 } |
|
391 |
|
392 // -------------------------------------------------------------------------- |
|
393 // CPbk2ContactViewListBox::SetScrollEventObserver |
|
394 // -------------------------------------------------------------------------- |
|
395 // |
|
396 void CPbk2ContactViewListBox::SetScrollEventObserver(MEikScrollBarObserver* aObserver) |
|
397 { |
|
398 iScrollEventObserver = aObserver; |
|
399 } |
|
400 |
|
401 // -------------------------------------------------------------------------- |
|
402 // CPbk2ContactViewListBox::IsSelectionListBox |
|
403 // This function is non const because IsMultiselection is non const. |
|
404 // -------------------------------------------------------------------------- |
|
405 // |
|
406 TBool CPbk2ContactViewListBox::IsSelectionListBox() |
|
407 { |
|
408 // Try firs the CEikListBox method for multiselection |
|
409 TBool result = IsMultiselection(); |
|
410 |
|
411 if ( !result ) |
|
412 { |
|
413 // Then try other flags |
|
414 TUint32 markableFlags = |
|
415 EAknListBoxStylusMarkableList | |
|
416 EAknListBoxStylusMultiselectionList | |
|
417 EAknListBoxMarkableList | |
|
418 EAknListBoxMultiselectionList; |
|
419 |
|
420 // Compare CEikListBox flags to Avkon markable list flags |
|
421 result = iListBoxFlags & markableFlags; |
|
422 } |
|
423 return result; |
|
424 } |
|
425 |
|
426 void CPbk2ContactViewListBox::SetListCommands( |
|
427 const RPointerArray<MPbk2UiControlCmdItem>* aCommands ) |
|
428 { |
|
429 iListboxModelDecorator->SetListCommands( aCommands ); |
|
430 iColumnData->SetListCommands( aCommands ); |
|
431 } |
|
432 |
|
433 // -------------------------------------------------------------------------- |
|
434 // CPbk2ContactViewListBox::ClipFromBeginning |
|
435 // -------------------------------------------------------------------------- |
|
436 // |
|
437 TBool CPbk2ContactViewListBox::ClipFromBeginning |
|
438 ( TDes& aBuffer, TInt aItemIndex, TInt aSubCellNumber ) |
|
439 { |
|
440 return AknTextUtils::ClipToFit( aBuffer, |
|
441 AknTextUtils::EClipFromBeginning, this, aItemIndex, |
|
442 aSubCellNumber ); |
|
443 } |
|
444 |
|
445 // -------------------------------------------------------------------------- |
|
446 // CPbk2ContactViewListBox::FocusedItemPointed |
|
447 // -------------------------------------------------------------------------- |
|
448 // |
|
449 TBool CPbk2ContactViewListBox::FocusedItemPointed() |
|
450 { |
|
451 return iFocusedContactPointed; |
|
452 } |
|
453 |
|
454 // -------------------------------------------------------------------------- |
|
455 // CPbk2ContactViewListBox::FocusableItemPointed |
|
456 // -------------------------------------------------------------------------- |
|
457 // |
|
458 TBool CPbk2ContactViewListBox::FocusableItemPointed() |
|
459 { |
|
460 return iFocusableContactPointed; |
|
461 } |
|
462 |
|
463 // -------------------------------------------------------------------------- |
|
464 // CPbk2ContactViewListBox::SearchFieldPointed |
|
465 // -------------------------------------------------------------------------- |
|
466 // |
|
467 TBool CPbk2ContactViewListBox::SearchFieldPointed() |
|
468 { |
|
469 return EFalse; |
|
470 } |
|
471 |
|
472 // -------------------------------------------------------------------------- |
|
473 // CPbk2ContactViewListBox::HandleScrollEventL |
|
474 // -------------------------------------------------------------------------- |
|
475 // |
|
476 void CPbk2ContactViewListBox::HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType) |
|
477 { |
|
478 // Handle showing of popupcharacter when user scrolls list using using scroll bar |
|
479 TBool prevState = iShowPopupChar; |
|
480 |
|
481 iShowPopupChar = ( aEventType == EEikScrollThumbDragHoriz || aEventType == EEikScrollThumbDragVert ); |
|
482 |
|
483 if( prevState != iShowPopupChar ) |
|
484 { |
|
485 DrawDeferred(); |
|
486 } |
|
487 |
|
488 CAknSingleGraphicStyleListBox::HandleScrollEventL( aScrollBar, aEventType ); |
|
489 if( iScrollEventObserver ) |
|
490 { |
|
491 iScrollEventObserver->HandleScrollEventL( aScrollBar, aEventType ); |
|
492 } |
|
493 } |
|
494 |
|
495 // -------------------------------------------------------------------------- |
|
496 // CPbk2ContactViewListBox::CreateListBoxModelL |
|
497 // -------------------------------------------------------------------------- |
|
498 // |
|
499 void CPbk2ContactViewListBox::CreateListBoxModelL |
|
500 ( const CVPbkContactManager& aManager, MVPbkContactViewBase& aView, |
|
501 MPbk2ContactNameFormatter& aNameFormatter, |
|
502 CPbk2StorePropertyArray& aStoreProperties ) |
|
503 { |
|
504 __ASSERT_DEBUG( !iModel && !iListboxModelDecorator, |
|
505 Panic( EPanicPreCond_CreateListBoxModelL ) ); |
|
506 |
|
507 // Set up listbox model |
|
508 CPbk2ContactViewListBoxModel::TParams params; |
|
509 params.iContactManager = &aManager; |
|
510 params.iView = &aView; |
|
511 params.iStoreProperties = &aStoreProperties; |
|
512 params.iNameFormatter = &aNameFormatter; |
|
513 params.iIconArray = IconArray( *this ); |
|
514 params.iEmptyId = iResourceData.iEmptyIconId; |
|
515 params.iDefaultId = iResourceData.iDefaultIconId; |
|
516 params.iClipListBoxText = this; |
|
517 params.iUiExtension = iUiExtension; |
|
518 params.iMultiselection = IsMultiselection(); |
|
519 CPbk2ContactViewListBoxModel* model = DoCreateModelL( params ); |
|
520 model->SetUnnamedText( iResourceData.iUnnamedText ); |
|
521 iModel = model; |
|
522 |
|
523 if(FeatureManager::FeatureSupported(KFeatureIdFfContactsPredictiveSearch)) |
|
524 { |
|
525 iColumnData->SetDataModel( iModel ); |
|
526 } |
|
527 // Wrap the original model. |
|
528 iListboxModelDecorator = DoCreateDecoratorL( |
|
529 *IconArray( *this ), |
|
530 iResourceData.iEmptyIconId, |
|
531 iResourceData.iDefaultIconId ); |
|
532 |
|
533 |
|
534 iListboxModelDecorator->SetDecoratedModel( *iModel ); |
|
535 Model()->SetItemTextArray( iListboxModelDecorator ); |
|
536 Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
537 } |
|
538 |
|
539 // -------------------------------------------------------------------------- |
|
540 // CPbk2ContactViewListBox::DoCreateModelL |
|
541 // -------------------------------------------------------------------------- |
|
542 // |
|
543 CPbk2ContactViewListBoxModel* CPbk2ContactViewListBox::DoCreateModelL( |
|
544 CPbk2ContactViewListBoxModel::TParams params ) |
|
545 { |
|
546 return CPbk2ContactViewListBoxModel::NewL( params ); |
|
547 } |
|
548 |
|
549 |
|
550 // -------------------------------------------------------------------------- |
|
551 // CPbk2ContactViewListBox::DoCreateDecoratorL |
|
552 // -------------------------------------------------------------------------- |
|
553 // |
|
554 CPbk2ListboxModelCmdDecorator* CPbk2ContactViewListBox::DoCreateDecoratorL( |
|
555 const CPbk2IconArray& aIconArray, |
|
556 TPbk2IconId aEmptyIconId, |
|
557 TPbk2IconId aDefaultIconId ) |
|
558 { |
|
559 return CPbk2ListboxModelCmdDecorator::NewL( |
|
560 aIconArray, |
|
561 aEmptyIconId, |
|
562 aDefaultIconId ); |
|
563 } |
|
564 |
|
565 |
|
566 // -------------------------------------------------------------------------- |
|
567 // CPbk2ContactViewListBox::IsContact |
|
568 // -------------------------------------------------------------------------- |
|
569 // |
|
570 TBool CPbk2ContactViewListBox::IsContact( TInt aIndex ) const |
|
571 { |
|
572 // The command items are always at the top of the list. |
|
573 return aIndex >= iListboxModelDecorator->NumberOfEnabledCommands(); |
|
574 } |
|
575 |
|
576 // -------------------------------------------------------------------------- |
|
577 // CPbk2ContactViewListBox::Draw |
|
578 // -------------------------------------------------------------------------- |
|
579 // |
|
580 void CPbk2ContactViewListBox::Draw( const TRect& aRect ) const |
|
581 { |
|
582 CAknSingleGraphicStyleListBox::Draw(aRect); |
|
583 |
|
584 CPbk2NamesListControl& listControl = static_cast<CPbk2NamesListControl&>(iContainer); |
|
585 TInt itemIndex = TopItemIndex() - listControl.CommandItemCount(); |
|
586 |
|
587 // itemIndex >= 0 filter out command item |
|
588 if ( itemIndex >= 0 && iShowPopupChar ) |
|
589 { |
|
590 // Handle showing of popupcharacter when user scrolls list using using scroll bar |
|
591 CWindowGc& gc = SystemGc(); |
|
592 |
|
593 TRgb normal; |
|
594 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), |
|
595 normal, |
|
596 KAknsIIDQsnTextColors, |
|
597 EAknsCIQsnTextColorsCG6 ); |
|
598 |
|
599 TAknLayoutRect layout; |
|
600 layout.LayoutRect(Rect(), AknLayoutScalable_Apps::popup_navstr_preview_pane(0)); |
|
601 |
|
602 TAknLayoutRect cornerRect; |
|
603 // skinned draw uses submenu popup window skin (skinned border) |
|
604 |
|
605 cornerRect.LayoutRect( |
|
606 layout.Rect(), |
|
607 SkinLayout::Submenu_skin_placing_Line_2() ); |
|
608 |
|
609 TRect innerRect( layout.Rect() ); |
|
610 innerRect.Shrink( cornerRect.Rect().Width(), cornerRect.Rect().Height() ); |
|
611 |
|
612 if ( !AknsDrawUtils::DrawFrame( |
|
613 AknsUtils::SkinInstance(), |
|
614 gc, |
|
615 layout.Rect(), |
|
616 innerRect, |
|
617 KAknsIIDQsnFrPopupSub, |
|
618 KAknsIIDQsnFrPopupCenterSubmenu ) ) |
|
619 { |
|
620 // skinned border failed -> black border |
|
621 gc.SetPenStyle( CGraphicsContext::ESolidPen ); |
|
622 gc.SetBrushColor( KRgbBlack ); |
|
623 gc.DrawRect( layout.Rect() ); |
|
624 } |
|
625 |
|
626 TAknLayoutText textLayout; |
|
627 textLayout.LayoutText(layout.Rect(), AknLayoutScalable_Apps::popup_navstr_preview_pane_t1(0).LayoutLine()); |
|
628 |
|
629 TPtrC desc(Model()->ItemTextArray()->MdcaPoint(View()->TopItemIndex())); |
|
630 |
|
631 HBufC* buf = desc.Mid(desc.Find(_L("\t")) + 1, 1).AllocL(); |
|
632 TPtr textPtr = buf->Des(); |
|
633 textPtr.UpperCase(); |
|
634 |
|
635 textLayout.DrawText(gc, textPtr, ETrue, normal ); |
|
636 |
|
637 delete buf; |
|
638 } |
|
639 |
|
640 } |
|
641 |
|
642 // -------------------------------------------------------------------------- |
|
643 // CPbk2ContactViewListBox::CreateItemDrawerL |
|
644 // -------------------------------------------------------------------------- |
|
645 // |
|
646 void CPbk2ContactViewListBox::CreateItemDrawerL() |
|
647 { |
|
648 CPbk2ContactViewCustomListBoxData* columnData = |
|
649 CPbk2ContactViewCustomListBoxData::NewL( iSearchFilter ); |
|
650 |
|
651 CleanupStack::PushL( columnData ); |
|
652 |
|
653 iItemDrawer=new(ELeave) CPbk2ContactViewCustomListBoxItemDrawer( |
|
654 static_cast<MTextListBoxModel*>(Model()), iCoeEnv->NormalFont(), |
|
655 columnData); |
|
656 CleanupStack::Pop( columnData ); |
|
657 |
|
658 //Ownership has been transferred to iItemDrawer |
|
659 iColumnData = columnData; |
|
660 } |
|
661 |
|
662 // -------------------------------------------------------------------------- |
|
663 // CPbk2ContactViewListBox::HandleGainingForeground |
|
664 // -------------------------------------------------------------------------- |
|
665 // |
|
666 void CPbk2ContactViewListBox::HandleGainingForeground() |
|
667 { |
|
668 } |
|
669 |
|
670 // -------------------------------------------------------------------------- |
|
671 // CPbk2ContactViewListBox::HandleLosingForeground |
|
672 // -------------------------------------------------------------------------- |
|
673 // |
|
674 void CPbk2ContactViewListBox::HandleLosingForeground() |
|
675 { |
|
676 if ( iShowPopupChar ) |
|
677 { |
|
678 //Simulate an EButton1Up event to force a DrawDeferred() calling |
|
679 //in case of the scrollbar¡¯s at the background that can¡¯t receive the EButton1Up event. |
|
680 TPointerEvent PointEvent; |
|
681 PointEvent.iType = TPointerEvent::EButton1Up ; |
|
682 TRAP_IGNORE( ScrollBarFrame()->VerticalScrollBar()->HandlePointerEventL( PointEvent ) ); |
|
683 DrawDeferred(); |
|
684 } |
|
685 } |
|
686 // End of File |