|
1 /* |
|
2 * Copyright (c) 2006 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: Implementation of common container for AVKON platform. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <barsread.h> |
|
22 #include <stringloader.h> |
|
23 #include <akniconarray.h> |
|
24 #include <gulicon.h> |
|
25 #include <featmgr.h> |
|
26 #include <aknsfld.h> |
|
27 #include <aknutils.h> |
|
28 #include <aknlists.h> |
|
29 #include <aknconsts.h> |
|
30 #include <avkon.mbg> |
|
31 #include <eikclbd.h> |
|
32 #include <eikcmobs.h> |
|
33 #include <bautils.h> |
|
34 |
|
35 #include <data_caging_path_literals.hrh> |
|
36 #include <mpxcommoncontainer.rsg> |
|
37 #include <mpxlog.h> |
|
38 #include <mpxuser.h> |
|
39 |
|
40 #include "mpxcommonlistboxarraybase.h" |
|
41 #include "mpxcommoncontaineravkonimp.h" |
|
42 #include "mpxcommoncontainer.hrh" |
|
43 #include <mpxlbxextendedfeatures.h> |
|
44 |
|
45 // CONSTANTS |
|
46 const TInt KMPXFindboxTextLimit = 40; |
|
47 |
|
48 _LIT( KMPXCommonContainerRscPath, "mpxcommoncontainer.rsc" ); |
|
49 |
|
50 // ======== MEMBER FUNCTIONS ======== |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // C++ constructor can NOT contain any code that might leave. |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 CMPXCommonContainerAvkonImp::CMPXCommonContainerAvkonImp() : |
|
57 iIsFindEnabled( ETrue ), |
|
58 iIsMarkingEnabled( ETrue ), |
|
59 iContainerActive( EFalse ) |
|
60 { |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // Destructor |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CMPXCommonContainerAvkonImp::~CMPXCommonContainerAvkonImp() |
|
68 { |
|
69 MPX_FUNC( "CMPXCommonContainerAvkonImp::~CMPXCommonContainerAvkonImp" ); |
|
70 |
|
71 FeatureManager::UnInitializeLib(); |
|
72 |
|
73 if ( iResourceOffset ) |
|
74 { |
|
75 iEikonEnv->DeleteResourceFile( iResourceOffset ); |
|
76 } |
|
77 |
|
78 delete iListBox; |
|
79 delete iFindBox; |
|
80 delete iLbxExtFeat; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // Return Coe Control |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 CCoeControl* CMPXCommonContainerAvkonImp::CoeControl() |
|
88 { |
|
89 MPX_FUNC( "CMPXCommonContainerAvkonImp::CoeControl" ); |
|
90 return this; |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // Set View Container |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 void CMPXCommonContainerAvkonImp::SetViewContainer( |
|
98 MMPXViewContainer* aViewContainer ) |
|
99 { |
|
100 MPX_FUNC( "CMPXCommonContainerAvkonImp::SetViewContainer" ); |
|
101 iViewContainer = aViewContainer; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // Set command observer for the container |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 void CMPXCommonContainerAvkonImp::SetCommandObserver( |
|
109 MEikCommandObserver* aCommandObserver ) |
|
110 { |
|
111 MPX_FUNC( "CMPXCommonContainerAvkonImp::SetCommandObserver" ); |
|
112 iView = aCommandObserver; |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // C++ constructor can NOT contain any code that might leave. |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 void CMPXCommonContainerAvkonImp::SetListBoxObserver( |
|
120 MEikListBoxObserver* aListBoxObserver ) |
|
121 { |
|
122 MPX_FUNC( "CMPXCommonContainerAvkonImp::SetListBoxObserver" ); |
|
123 iListBoxObserver = aListBoxObserver; |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // Set layout for all elements and set sizes for icons. |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 void CMPXCommonContainerAvkonImp::UpdateLayout() |
|
131 { |
|
132 MPX_FUNC( "CMPXCommonContainerAvkonImp::UpdateLayout" ); |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // Returns a pointer to the listboxarray |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 CMPXCommonListBoxArrayBase* CMPXCommonContainerAvkonImp::ListBoxArray() const |
|
140 { |
|
141 ASSERT( iListBoxArray ); |
|
142 return iListBoxArray; |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // Sets listbox array |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 void CMPXCommonContainerAvkonImp::SetListBoxArrayL( |
|
150 CMPXCommonListBoxArrayBase* aListBoxArray ) |
|
151 { |
|
152 iListBoxArray = aListBoxArray; |
|
153 if ( iListBoxArray ) |
|
154 { |
|
155 CTextListBoxModel* listboxModel = iListBox->Model(); |
|
156 listboxModel->SetItemTextArray( iListBoxArray ); |
|
157 listboxModel->SetOwnershipType( ELbmOwnsItemArray ); |
|
158 } |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // Return number of listbox items shown in the current listbox. |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 TInt CMPXCommonContainerAvkonImp::CurrentListItemCount() const |
|
166 { |
|
167 MPX_FUNC( "CMPXCommonContainerAvkonImp::CurrentListItemCount" ); |
|
168 ASSERT( iFindBoxFilterItems ); |
|
169 return iFindBoxFilterItems->FilteredNumberOfItems(); |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // Return total number of listbox items in the listbox. |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 TInt CMPXCommonContainerAvkonImp::TotalListItemCount() const |
|
177 { |
|
178 MPX_FUNC( "CMPXCommonContainerAvkonImp::TotalListItemCount" ); |
|
179 ASSERT( iFindBoxFilterItems ); |
|
180 return iFindBoxFilterItems->NonFilteredNumberOfItems(); |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // Gets top listbox item index (relative to the original listbox). |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 TInt CMPXCommonContainerAvkonImp::TopLbxItemIndex() const |
|
188 { |
|
189 MPX_FUNC( "CMPXCommonContainerAvkonImp::TopLbxItemIndex" ); |
|
190 ASSERT( iListBox ); |
|
191 ASSERT( iFindBoxFilterItems ); |
|
192 TInt topItem( iListBox->TopItemIndex() ); |
|
193 |
|
194 // Make sure there's at least one item in the listbox |
|
195 if ( iFindBoxFilterItems->FilteredNumberOfItems() ) |
|
196 { |
|
197 // Get the real listbox index |
|
198 topItem = iFindBoxFilterItems->FilteredItemIndex( topItem ); |
|
199 } |
|
200 return topItem; |
|
201 } |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // Gets bottom listbox item index (relative to the original listbox). |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 TInt CMPXCommonContainerAvkonImp::BottomLbxItemIndex() const |
|
208 { |
|
209 MPX_FUNC( "CMPXCommonContainerAvkonImp::BottomLbxItemIndex" ); |
|
210 ASSERT( iListBox ); |
|
211 ASSERT( iFindBoxFilterItems ); |
|
212 TInt bottomItem( iListBox->BottomItemIndex() ); |
|
213 |
|
214 // Make sure there's at least one item in the listbox |
|
215 if ( iFindBoxFilterItems->FilteredNumberOfItems() ) |
|
216 { |
|
217 // Get the real listbox index |
|
218 bottomItem = iFindBoxFilterItems->FilteredItemIndex( bottomItem ); |
|
219 } |
|
220 return bottomItem; |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // Gets current listbox item index (relative to the original listbox). |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 TInt CMPXCommonContainerAvkonImp::CurrentLbxItemIndex() const |
|
228 { |
|
229 MPX_FUNC( "CMPXCommonContainerAvkonImp::CurrentLbxItemIndex" ); |
|
230 ASSERT( iListBox ); |
|
231 ASSERT( iFindBoxFilterItems ); |
|
232 TInt currentItem( iListBox->CurrentItemIndex() ); |
|
233 |
|
234 // Make sure there's at least one item in the listbox |
|
235 if ( iFindBoxFilterItems->FilteredNumberOfItems() ) |
|
236 { |
|
237 // Get the real listbox index |
|
238 currentItem = iFindBoxFilterItems->FilteredItemIndex( currentItem ); |
|
239 } |
|
240 return currentItem; |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // Get current selected listbox items indices (relative to the original listbox) |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 const CArrayFix<TInt>* CMPXCommonContainerAvkonImp:: |
|
248 CurrentSelectionIndicesL() const |
|
249 { |
|
250 MPX_FUNC( "CMPXCommonContainerAvkonImp::CurrentSelectionIndicesL" ); |
|
251 ASSERT( iListBox ); |
|
252 ASSERT( iFindBoxFilterItems ); |
|
253 const CArrayFix<TInt>* selectionArray( iListBox->SelectionIndexes() ); |
|
254 |
|
255 if ( iFindBoxFilterItems->FilteredNumberOfItems() ) |
|
256 { |
|
257 // Get the real listbox indices |
|
258 iFindBoxFilterItems->SelectionIndexes()->Reset(); |
|
259 iFindBoxFilterItems->UpdateSelectionIndexesL(); |
|
260 selectionArray = iFindBoxFilterItems->SelectionIndexes(); |
|
261 } |
|
262 return selectionArray; |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // Get current selected listbox items indices (relative to the original listbox) |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 void CMPXCommonContainerAvkonImp::SetCurrentSelectionIndicesL( |
|
270 CArrayFix<TInt>* aIndices ) const |
|
271 { |
|
272 MPX_FUNC( "CMPXCommonContainerAvkonImp::SetCurrentSelectionIndicesL" ); |
|
273 ASSERT( iListBox ); |
|
274 iListBox->SetSelectionIndexesL( aIndices ); // ownership not transfered |
|
275 } |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // Set top listbox item index. |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 void CMPXCommonContainerAvkonImp::SetLbxTopItemIndex( TInt aIndex ) |
|
282 { |
|
283 MPX_FUNC( "CMPXCommonContainerAvkonImp::SetLbxTopItemIndex" ); |
|
284 ASSERT( iListBox ); |
|
285 ASSERT( iFindBoxFilterItems ); |
|
286 TInt index( iFindBoxFilterItems->VisibleItemIndex( aIndex ) ); |
|
287 if ( index == KErrNotFound ) |
|
288 { |
|
289 index = 0; |
|
290 } |
|
291 iListBox->SetTopItemIndex( index ); |
|
292 } |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // Set current listbox item index. |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 void CMPXCommonContainerAvkonImp::SetLbxCurrentItemIndex( TInt aIndex ) |
|
299 { |
|
300 MPX_FUNC( "CMPXCommonContainerAvkonImp::SetLbxCurrentItemIndex" ); |
|
301 ASSERT( iListBox ); |
|
302 ASSERT( iFindBoxFilterItems ); |
|
303 TInt index( iFindBoxFilterItems->VisibleItemIndex( aIndex ) ); |
|
304 if ( index == KErrNotFound ) |
|
305 { |
|
306 index = 0; |
|
307 } |
|
308 iListBox->SetCurrentItemIndex( index ); |
|
309 } |
|
310 |
|
311 // ----------------------------------------------------------------------------- |
|
312 // Set current listbox item index and highlight it. |
|
313 // ----------------------------------------------------------------------------- |
|
314 // |
|
315 void CMPXCommonContainerAvkonImp::SetLbxCurrentItemIndexAndDraw( |
|
316 TInt aIndex ) |
|
317 { |
|
318 MPX_FUNC( "CMPXCommonContainerAvkonImp::SetLbxCurrentItemIndexAndDraw" ); |
|
319 ASSERT( iListBox ); |
|
320 ASSERT( iFindBoxFilterItems ); |
|
321 TInt index( iFindBoxFilterItems->VisibleItemIndex( aIndex ) ); |
|
322 if ( index == KErrNotFound ) |
|
323 { |
|
324 index = 0; |
|
325 } |
|
326 iListBox->SetCurrentItemIndexAndDraw( index ); |
|
327 } |
|
328 |
|
329 // ----------------------------------------------------------------------------- |
|
330 // Clear listbox selection. |
|
331 // ----------------------------------------------------------------------------- |
|
332 // |
|
333 void CMPXCommonContainerAvkonImp::ClearLbxSelection() |
|
334 { |
|
335 MPX_FUNC( "CMPXCommonContainerAvkonImp::ClearLbxSelection" ); |
|
336 ASSERT( iListBox ); |
|
337 ASSERT( iFindBoxFilterItems ); |
|
338 iListBox->ClearSelection(); |
|
339 iFindBoxFilterItems->SelectionIndexes()->Reset(); |
|
340 } |
|
341 |
|
342 // ----------------------------------------------------------------------------- |
|
343 // Sets the text for an empty list box |
|
344 // ----------------------------------------------------------------------------- |
|
345 // |
|
346 void CMPXCommonContainerAvkonImp::SetLbxEmptyTextL( const TDesC& aText ) |
|
347 { |
|
348 ASSERT( iListBox ); |
|
349 iListBox->View()->SetListEmptyTextL( aText ); |
|
350 } |
|
351 |
|
352 // ----------------------------------------------------------------------------- |
|
353 // Draws a list box item |
|
354 // ----------------------------------------------------------------------------- |
|
355 // |
|
356 void CMPXCommonContainerAvkonImp::DrawLbxItem( TInt aIndex ) |
|
357 { |
|
358 ASSERT( iListBox ); |
|
359 TInt topIndex( TopLbxItemIndex() ); |
|
360 TInt bottomIndex( BottomLbxItemIndex() ); |
|
361 if ( aIndex >= topIndex && aIndex <= bottomIndex ) |
|
362 { |
|
363 iListBox->DrawItem( aIndex ); |
|
364 } |
|
365 } |
|
366 |
|
367 // ----------------------------------------------------------------------------- |
|
368 // Set Find box's focus. |
|
369 // ----------------------------------------------------------------------------- |
|
370 // |
|
371 void CMPXCommonContainerAvkonImp::SetFindBoxFocus( TBool aFocus ) |
|
372 { |
|
373 MPX_FUNC( "CMPXCommonContainerAvkonImp::SetFindBoxFocus" ); |
|
374 ASSERT( iFindBox ); |
|
375 if ( aFocus ) |
|
376 { |
|
377 iFindBox->MakeVisible( ETrue ); |
|
378 } |
|
379 iFindBox->SetFocus( aFocus ); |
|
380 } |
|
381 |
|
382 // ----------------------------------------------------------------------------- |
|
383 // Handle listbox item addition. |
|
384 // ----------------------------------------------------------------------------- |
|
385 // |
|
386 void CMPXCommonContainerAvkonImp::HandleLbxItemAdditionL() |
|
387 { |
|
388 MPX_FUNC( "CMPXCommonContainerAvkonImp::HandleLbxItemAdditionL" ); |
|
389 ASSERT( iListBox ); |
|
390 ASSERT( iFindBoxFilterItems ); |
|
391 iFindBoxFilterItems->HandleItemArrayChangeL(); |
|
392 iListBox->HandleItemAdditionL(); |
|
393 } |
|
394 |
|
395 // ----------------------------------------------------------------------------- |
|
396 // Handle listbox item addition, preserving the current display index |
|
397 // ----------------------------------------------------------------------------- |
|
398 // |
|
399 void CMPXCommonContainerAvkonImp::HandleLbxItemAdditionPreserveIndexL() |
|
400 { |
|
401 MPX_FUNC( "CMPXCommonContainerAvkonImp::HandleLbxItemAdditionPreserveIndexL" ); |
|
402 TInt currentItem( CurrentLbxItemIndex() ); |
|
403 TInt currentBottomIndex( BottomLbxItemIndex() ); |
|
404 TInt topIndex( CalculateTopIndex( currentBottomIndex ) ); |
|
405 HandleLbxItemAdditionL(); |
|
406 if ( currentItem > 0 ) |
|
407 { |
|
408 // only redraw if the selected index is > 0, since |
|
409 // HandleLbxItemAdditionL already redraws it and set index |
|
410 // to 0 |
|
411 SetLbxTopItemIndex( topIndex ); |
|
412 SetLbxCurrentItemIndexAndDraw( currentItem ); |
|
413 } |
|
414 } |
|
415 |
|
416 // ----------------------------------------------------------------------------- |
|
417 // Handle listbox item removal. |
|
418 // ----------------------------------------------------------------------------- |
|
419 // |
|
420 void CMPXCommonContainerAvkonImp::HandleLbxItemRemovalL() |
|
421 { |
|
422 MPX_FUNC( "CMPXCommonContainerAvkonImp::HandleLbxItemRemovalL" ); |
|
423 ASSERT( iListBox ); |
|
424 iListBox->HandleItemRemovalL(); |
|
425 } |
|
426 |
|
427 // ----------------------------------------------------------------------------- |
|
428 // Show/hide find box. |
|
429 // ----------------------------------------------------------------------------- |
|
430 // |
|
431 void CMPXCommonContainerAvkonImp::SetFindBoxVisibilityL( TBool aIsVisible ) |
|
432 { |
|
433 MPX_FUNC( "CMPXCommonContainerAvkonImp::SetFindBoxVisibilityL" ); |
|
434 ASSERT( iListBox ); |
|
435 ASSERT( iFindBox ); |
|
436 if (aIsVisible != iFindBox->IsVisible()) |
|
437 { |
|
438 iFindBox->MakeVisible( aIsVisible ); |
|
439 iFindBox->SetFocus( aIsVisible ); |
|
440 if ( !aIsVisible ) |
|
441 { |
|
442 iFindBox->ResetL(); |
|
443 iFindBoxFilterItems->HandleOfferkeyEventL(); |
|
444 iListBox->SetFocus( ETrue ); |
|
445 } |
|
446 SizeChanged(); |
|
447 DrawDeferred(); |
|
448 } |
|
449 } |
|
450 |
|
451 // ----------------------------------------------------------------------------- |
|
452 // Determine find box visibility |
|
453 // ----------------------------------------------------------------------------- |
|
454 // |
|
455 TBool CMPXCommonContainerAvkonImp::FindBoxVisibility() |
|
456 { |
|
457 MPX_FUNC( "CMPXCommonContainerAvkonImp::FindBoxVisibility" ); |
|
458 ASSERT( iFindBox ); |
|
459 return iFindBox->IsVisible(); |
|
460 } |
|
461 |
|
462 // ----------------------------------------------------------------------------- |
|
463 // Restore the PopupCBA of find box |
|
464 // ----------------------------------------------------------------------------- |
|
465 // |
|
466 void CMPXCommonContainerAvkonImp::RestoreFindBoxPopupCBA() |
|
467 { |
|
468 MPX_FUNC( "CMPXCommonContainerAvkonImp::RestoreFindBoxPopupCBA" ); |
|
469 ASSERT( iFindBox ); |
|
470 iFindBox->SetFocus( ETrue ); |
|
471 iFindBox->SetFocus( EFalse ); |
|
472 } |
|
473 |
|
474 // ----------------------------------------------------------------------------- |
|
475 // Calculate the top index of the visible items |
|
476 // ----------------------------------------------------------------------------- |
|
477 // |
|
478 TInt CMPXCommonContainerAvkonImp::CalculateTopIndex( TInt aBottomIndex ) |
|
479 { |
|
480 MPX_FUNC( "CMPXCommonContainerAvkonImp::CalculateTopIndex" ); |
|
481 ASSERT( iListBox ); |
|
482 TInt numItems( iListBox->View()->NumberOfItemsThatFitInRect( |
|
483 iListBox->View()->ViewRect() ) - 1 ); // to make it 0 based |
|
484 return ( ( aBottomIndex > numItems ) ? aBottomIndex - numItems : 0 ); |
|
485 } |
|
486 |
|
487 // --------------------------------------------------------------------------- |
|
488 // Symbian 2nd phase constructor can leave. |
|
489 // --------------------------------------------------------------------------- |
|
490 // |
|
491 void CMPXCommonContainerAvkonImp::ConstructContainerL( TMPXCommonContainerCollectionType /*aCollectionType*/ ) |
|
492 { |
|
493 MPX_FUNC( "CMPXCommonContainerAvkonImp::ConstructContainerL" ); |
|
494 |
|
495 CCoeEnv* coeEnv( iEikonEnv ); |
|
496 TParse parse; |
|
497 parse.Set( KMPXCommonContainerRscPath, &KDC_APP_RESOURCE_DIR, NULL ); |
|
498 TFileName resourceFile( parse.FullName() ); |
|
499 User::LeaveIfError( MPXUser::CompleteWithDllPath( resourceFile ) ); |
|
500 BaflUtils::NearestLanguageFile( coeEnv->FsSession(), resourceFile ); |
|
501 iResourceOffset = coeEnv->AddResourceFileL( resourceFile ); |
|
502 |
|
503 CreateWindowL(); |
|
504 |
|
505 CreateListBoxL(); |
|
506 |
|
507 FeatureManager::InitializeLibL(); |
|
508 |
|
509 ConstructFindBoxL( ETrue ); |
|
510 } |
|
511 |
|
512 // --------------------------------------------------------------------------- |
|
513 // Enable/disable find box |
|
514 // --------------------------------------------------------------------------- |
|
515 // |
|
516 void CMPXCommonContainerAvkonImp::EnableFindBox( TBool aEnable ) |
|
517 { |
|
518 MPX_FUNC( "CMPXCommonContainerAvkonImp::EnableFindBox" ); |
|
519 iIsFindEnabled = aEnable; |
|
520 if ( !aEnable ) |
|
521 { |
|
522 TRAP_IGNORE(SetFindBoxVisibilityL( EFalse )); |
|
523 }; |
|
524 } |
|
525 |
|
526 // --------------------------------------------------------------------------- |
|
527 // Enable/disable marking |
|
528 // --------------------------------------------------------------------------- |
|
529 // |
|
530 void CMPXCommonContainerAvkonImp::EnableMarking( TBool aEnable ) |
|
531 { |
|
532 MPX_FUNC( "CMPXCommonContainerAvkonImp::EnableMarking" ); |
|
533 iIsMarkingEnabled = aEnable; |
|
534 } |
|
535 |
|
536 // --------------------------------------------------------------------------- |
|
537 // Custom handling of commands for markable lists. |
|
538 // --------------------------------------------------------------------------- |
|
539 // |
|
540 void CMPXCommonContainerAvkonImp::HandleMarkableListProcessCommandL( TInt aCommand ) |
|
541 { |
|
542 MPX_FUNC( "CMPXCommonContainerAvkonImp::HandleMarkableListProcessCommandL" ); |
|
543 ASSERT( iListBox ); |
|
544 |
|
545 // Handle in helper function |
|
546 AknSelectionService::HandleMarkableListProcessCommandL( |
|
547 aCommand, |
|
548 iListBox ); |
|
549 } |
|
550 |
|
551 // --------------------------------------------------------------------------- |
|
552 // Custom handling of menu pane for markable lists |
|
553 // --------------------------------------------------------------------------- |
|
554 // |
|
555 void CMPXCommonContainerAvkonImp::HandleMarkableListDynInitMenuPane( |
|
556 TInt aResourceId, |
|
557 CEikMenuPane* aMenuPane ) |
|
558 { |
|
559 MPX_FUNC( "CMPXCommonContainerAvkonImp::HandleMarkableListDynInitMenuPane" ); |
|
560 ASSERT( iListBox ); |
|
561 |
|
562 // Handle in helper function |
|
563 AknSelectionService::HandleMarkableListDynInitMenuPane( |
|
564 aResourceId, |
|
565 aMenuPane, |
|
566 iListBox ); |
|
567 } |
|
568 |
|
569 // --------------------------------------------------------------------------- |
|
570 // Handles key events. |
|
571 // --------------------------------------------------------------------------- |
|
572 // |
|
573 TKeyResponse CMPXCommonContainerAvkonImp::HandleKeyEventL( |
|
574 const TKeyEvent& aKeyEvent, |
|
575 TEventCode aType ) |
|
576 { |
|
577 ASSERT( iListBox ); |
|
578 ASSERT( iFindBox ); |
|
579 MPX_DEBUG5( "CMPXCommonContainerAvkonImp::HandleKeyEventL(iCode=%d, iScanCode=%d, iModifiers=0x%x, aType=%d)", |
|
580 aKeyEvent.iCode, aKeyEvent.iScanCode, aKeyEvent.iModifiers, aType ); |
|
581 |
|
582 TKeyResponse response( EKeyWasNotConsumed ); |
|
583 |
|
584 // Pass the key event to the common container components |
|
585 if ( iIsFindEnabled && |
|
586 ( ( iFindBox->IsVisible() ) || |
|
587 ( aKeyEvent.iCode != EKeyBackspace ) ) ) |
|
588 { |
|
589 TBool needRefresh( EFalse ); |
|
590 |
|
591 if ( aKeyEvent.iCode == EKeyBackspace && |
|
592 iFindBox->TextLength() == 0 ) |
|
593 { |
|
594 // dismiss find box |
|
595 SetFindBoxVisibilityL( EFalse ); |
|
596 response = EKeyWasConsumed; |
|
597 } |
|
598 else |
|
599 { |
|
600 // Offers the key event to find box. |
|
601 response = AknFind::HandleFindOfferKeyEventL( |
|
602 aKeyEvent, aType, this, iListBox, iFindBox, iIsFindPopup, |
|
603 needRefresh ); |
|
604 } |
|
605 |
|
606 if ( response == EKeyWasConsumed ) |
|
607 { |
|
608 if ( needRefresh ) |
|
609 { |
|
610 SizeChanged(); |
|
611 DrawNow(); |
|
612 } |
|
613 // If it's consumed by the findbox, there's no need to check |
|
614 // with listbox. |
|
615 return response; |
|
616 } |
|
617 } |
|
618 if ( ( aKeyEvent.iCode != EKeyLeftArrow ) && |
|
619 ( aKeyEvent.iCode != EKeyRightArrow ) && |
|
620 ( aKeyEvent.iCode != EKeyBackspace ) ) |
|
621 { |
|
622 // now it's iListBox's job to process the key event |
|
623 if ( !iIsMarkingEnabled && |
|
624 ( aKeyEvent.iCode == EKeyUpArrow || |
|
625 aKeyEvent.iCode == EKeyDownArrow || |
|
626 aKeyEvent.iCode == EKeyOK ) ) |
|
627 { |
|
628 // if marking is not enabled, check if this is marking command |
|
629 if ( aKeyEvent.iModifiers & EModifierLeftShift || |
|
630 aKeyEvent.iModifiers & EModifierRightShift || |
|
631 aKeyEvent.iModifiers & EModifierShift ) |
|
632 { |
|
633 // strip the marking command, and let list box handle it |
|
634 TKeyEvent modKeyEvent( aKeyEvent ); |
|
635 modKeyEvent.iModifiers &= ~EModifierLeftShift; |
|
636 modKeyEvent.iModifiers &= ~EModifierRightShift; |
|
637 modKeyEvent.iModifiers &= ~EModifierShift; |
|
638 response = iLbxExtFeat->HandleLbxKeyEventL( modKeyEvent, aType ); |
|
639 } |
|
640 else |
|
641 { |
|
642 // not marking command |
|
643 response = iLbxExtFeat->HandleLbxKeyEventL( aKeyEvent, aType ); |
|
644 } |
|
645 } |
|
646 else // marking is enabled |
|
647 { |
|
648 response = iLbxExtFeat->HandleLbxKeyEventL( aKeyEvent, aType ); |
|
649 |
|
650 #ifdef __ENABLE_MSK |
|
651 // check for marking command |
|
652 if ( ( aKeyEvent.iModifiers & EModifierLeftShift || |
|
653 aKeyEvent.iModifiers & EModifierRightShift || |
|
654 aKeyEvent.iModifiers & EModifierShift || |
|
655 aKeyEvent.iScanCode == EStdKeyDevice3 || |
|
656 iIsFindPopup ) && aType == EEventKeyUp ) |
|
657 { |
|
658 // Update the middle softkey for marking commands |
|
659 iView->ProcessCommandL( EMPXCmdCommonUpdateMiddleSoftKey ); |
|
660 } |
|
661 #endif // __ENABLE_MSK |
|
662 } |
|
663 } |
|
664 |
|
665 if ( response == EKeyWasNotConsumed && |
|
666 aType == EEventKey && |
|
667 aKeyEvent.iCode == EKeyBackspace && iView ) |
|
668 { |
|
669 iView->ProcessCommandL( EMPXCmdCommonDelete ); |
|
670 response = EKeyWasConsumed; |
|
671 } |
|
672 |
|
673 return response; |
|
674 } |
|
675 |
|
676 // --------------------------------------------------------------------------- |
|
677 // Activate container |
|
678 // --------------------------------------------------------------------------- |
|
679 // |
|
680 void CMPXCommonContainerAvkonImp::ActivateContainerL() |
|
681 { |
|
682 // Activate the container via Coe Control |
|
683 CCoeControl::ActivateL(); |
|
684 iContainerActive = ETrue; |
|
685 } |
|
686 |
|
687 // --------------------------------------------------------------------------- |
|
688 // Deactivate container |
|
689 // --------------------------------------------------------------------------- |
|
690 // |
|
691 void CMPXCommonContainerAvkonImp::DeactivateContainerL() |
|
692 { |
|
693 iContainerActive = EFalse; |
|
694 } |
|
695 |
|
696 // --------------------------------------------------------------------------- |
|
697 // Return container state |
|
698 // --------------------------------------------------------------------------- |
|
699 // |
|
700 TBool CMPXCommonContainerAvkonImp::IsContainerActive() |
|
701 { |
|
702 return iContainerActive; |
|
703 } |
|
704 |
|
705 // --------------------------------------------------------------------------- |
|
706 // From MMPXCommonListBoxArrayObserver |
|
707 // Handle listbox array events. |
|
708 // --------------------------------------------------------------------------- |
|
709 // |
|
710 void CMPXCommonContainerAvkonImp::HandleListBoxArrayEventL( |
|
711 MMPXCommonListBoxArrayObserver::TMPXCommonListBoxArrayEvents aEvent ) |
|
712 { |
|
713 MPX_FUNC( "CMPXCommonContainerAvkonImp::HandleListBoxArrayEventL" ); |
|
714 if ( aEvent == MMPXCommonListBoxArrayObserver::EMPXCommonListBoxArrayEventIconArrayChange ) |
|
715 { |
|
716 delete iIconArray; |
|
717 iIconArray = NULL; |
|
718 CreateIconArrayL(); |
|
719 static_cast<CEikColumnListBox*>( iListBox )->ItemDrawer()->ColumnData()-> |
|
720 SetIconArray( iIconArray ); |
|
721 } |
|
722 } |
|
723 |
|
724 // --------------------------------------------------------------------------- |
|
725 // From CCoeControl |
|
726 // Responds to changes to the size and position of the contents of this |
|
727 // control. |
|
728 // --------------------------------------------------------------------------- |
|
729 // |
|
730 void CMPXCommonContainerAvkonImp::SizeChanged() |
|
731 { |
|
732 MPX_FUNC( "CMPXCommonContainerAvkonImp::SizeChanged" ); |
|
733 |
|
734 if ( iIsFindPopup ) |
|
735 { |
|
736 AknFind::HandlePopupFindSizeChanged( |
|
737 this, |
|
738 static_cast<CAknColumnListBox*>( iListBox ), |
|
739 iFindBox ); |
|
740 } |
|
741 else |
|
742 { |
|
743 AknFind::HandleFixedFindSizeChanged( |
|
744 this, |
|
745 static_cast<CAknColumnListBox*>( iListBox ), |
|
746 iFindBox ); |
|
747 } |
|
748 } |
|
749 |
|
750 // --------------------------------------------------------------------------- |
|
751 // From CCoeControl |
|
752 // Gets the number of controls contained in a compound control. |
|
753 // --------------------------------------------------------------------------- |
|
754 // |
|
755 TInt CMPXCommonContainerAvkonImp::CountComponentControls() const |
|
756 { |
|
757 MPX_FUNC( "CMPXCommonContainerAvkonImp::CountComponentControls" ); |
|
758 ASSERT( iListBox ); |
|
759 ASSERT( iFindBox ); |
|
760 return 2; // number of components |
|
761 } |
|
762 |
|
763 // --------------------------------------------------------------------------- |
|
764 // From CCoeControl |
|
765 // Gets an indexed component of a compound control. |
|
766 // --------------------------------------------------------------------------- |
|
767 // |
|
768 CCoeControl* CMPXCommonContainerAvkonImp::ComponentControl( TInt aIndex ) const |
|
769 { |
|
770 MPX_FUNC( "CMPXCommonContainerAvkonImp::ComponentControl" ); |
|
771 CCoeControl* control( NULL ); |
|
772 switch ( aIndex ) |
|
773 { |
|
774 case 0: |
|
775 { |
|
776 control = iListBox; // Returns the pointer to listbox object. |
|
777 break; |
|
778 } |
|
779 case 1: |
|
780 { |
|
781 control = iFindBox; // Returns the pointer to findbox object. |
|
782 break; |
|
783 } |
|
784 default: |
|
785 { |
|
786 MPX_DEBUG1( "CMPXCommonContainerAvkonImp::ComponentControl out of range" ); |
|
787 ASSERT( 0 ); |
|
788 break; |
|
789 } |
|
790 } |
|
791 return control; |
|
792 } |
|
793 |
|
794 // --------------------------------------------------------------------------- |
|
795 // From CCoeControl |
|
796 // Handles key events. |
|
797 // --------------------------------------------------------------------------- |
|
798 // |
|
799 TKeyResponse CMPXCommonContainerAvkonImp::OfferKeyEventL( |
|
800 const TKeyEvent& aKeyEvent, |
|
801 TEventCode aType ) |
|
802 { |
|
803 ASSERT( iViewContainer ); |
|
804 MPX_DEBUG5( "CMPXCommonContainerAvkonImp::OfferKeyEventL(iCode=%d, iScanCode=%d, iModifiers=0x%x, aType=%d)", |
|
805 aKeyEvent.iCode, aKeyEvent.iScanCode, aKeyEvent.iModifiers, aType ); |
|
806 |
|
807 // Let the view container handle the key event. |
|
808 return iViewContainer->HandleKeyEventL( aKeyEvent, aType ); |
|
809 } |
|
810 |
|
811 // --------------------------------------------------------------------------- |
|
812 // Gets the control's help context. |
|
813 // --------------------------------------------------------------------------- |
|
814 // |
|
815 void CMPXCommonContainerAvkonImp::GetHelpContext( |
|
816 TCoeHelpContext& aContext ) const |
|
817 { |
|
818 ASSERT( iViewContainer ); |
|
819 MPX_FUNC( "CMPXCommonContainerAvkonImp::GetHelpContext" ); |
|
820 // Let the view container handle the help context retrieval |
|
821 iViewContainer->HandleHelpContext( aContext ); |
|
822 } |
|
823 |
|
824 // --------------------------------------------------------------------------- |
|
825 // From CCoeControl |
|
826 // Handles a change to the control's resources. |
|
827 // --------------------------------------------------------------------------- |
|
828 // |
|
829 void CMPXCommonContainerAvkonImp::HandleResourceChange( TInt aType ) |
|
830 { |
|
831 MPX_FUNC( "CMPXCommonContainerAvkonImp::HandleResourceChange" ); |
|
832 CCoeControl::HandleResourceChange( aType ); |
|
833 |
|
834 TRAP_IGNORE( |
|
835 if ( aType == KAknsMessageSkinChange ) |
|
836 { |
|
837 delete iIconArray; |
|
838 iIconArray = NULL; |
|
839 CreateIconArrayL(); |
|
840 static_cast<CEikColumnListBox*>( iListBox )->ItemDrawer()->ColumnData()-> |
|
841 SetIconArray( iIconArray ); |
|
842 } |
|
843 else if ( aType == KEikDynamicLayoutVariantSwitch && iView ) |
|
844 { |
|
845 iView->ProcessCommandL( EMPXCmdCommonResourceChange ); |
|
846 } ); |
|
847 } |
|
848 |
|
849 // --------------------------------------------------------------------------- |
|
850 // Create list box |
|
851 // --------------------------------------------------------------------------- |
|
852 // |
|
853 void CMPXCommonContainerAvkonImp::CreateListBoxL() |
|
854 { |
|
855 MPX_FUNC( "CMPXCommonContainerAvkonImp::CreateListBox" ); |
|
856 |
|
857 iListBox = new ( ELeave ) CAknSingleGraphicStyleListBox(); |
|
858 iListBox->SetContainerWindowL( *this ); |
|
859 iListBox->CreateScrollBarFrameL( ETrue ); |
|
860 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
861 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
862 |
|
863 TResourceReader reader; |
|
864 iCoeEnv->CreateResourceReaderLC( reader, R_MPX_COMMON_CONTAINER_LBX ); |
|
865 // construct's iListBox from resource file |
|
866 iListBox->ConstructFromResourceL( reader ); |
|
867 CleanupStack::PopAndDestroy(); // reader |
|
868 |
|
869 // Enable Marquee |
|
870 CEikColumnListBox* eikListbox = static_cast<CEikColumnListBox*>( iListBox ); |
|
871 eikListbox->EnableExtendedDrawingL(); |
|
872 eikListbox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue ); |
|
873 eikListbox->ItemDrawer()->ColumnData()->SetMarqueeParams( |
|
874 KMaxTInt, 6, 1000000); // Magic: loop forever, other params as default |
|
875 |
|
876 iListBox->SetListBoxObserver( iListBoxObserver ); |
|
877 |
|
878 // Speed Scrolling |
|
879 delete iLbxExtFeat; |
|
880 iLbxExtFeat = NULL; |
|
881 iLbxExtFeat = CMPXLbxExtendedFeatures::NewL( iListBox, ETrue ); |
|
882 iLbxExtFeat->EnableSpeedScrollL( ETrue ); |
|
883 |
|
884 } |
|
885 |
|
886 // ----------------------------------------------------------------------------- |
|
887 // Constructs Find box. |
|
888 // ----------------------------------------------------------------------------- |
|
889 // |
|
890 void CMPXCommonContainerAvkonImp::ConstructFindBoxL( TBool aIsFindPopup ) |
|
891 { |
|
892 MPX_FUNC( "CMPXCommonContainerAvkonImp::ConstructFindBoxL" ); |
|
893 CAknFilteredTextListBoxModel* lbxModel = |
|
894 static_cast<CAknFilteredTextListBoxModel*>( iListBox->Model() ); |
|
895 |
|
896 iIsFindPopup = aIsFindPopup; |
|
897 |
|
898 CAknSearchField::TSearchFieldStyle flag( |
|
899 iIsFindPopup ? CAknSearchField::EPopup : CAknSearchField::ESearch ); |
|
900 |
|
901 iFindBox = CAknSearchField::NewL( |
|
902 *this, flag, NULL, KMPXFindboxTextLimit ); |
|
903 lbxModel->CreateFilterL( iListBox, iFindBox ); |
|
904 iFindBoxFilterItems = lbxModel->Filter(); |
|
905 |
|
906 // Limit Japanese input modes |
|
907 if ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) ) |
|
908 { |
|
909 CEikEdwin& findEditor = iFindBox->Editor(); |
|
910 |
|
911 findEditor.SetAknEditorInputMode( EAknEditorKatakanaInputMode ); |
|
912 |
|
913 findEditor.SetAknEditorAllowedInputModes( |
|
914 EAknEditorKatakanaInputMode | |
|
915 EAknEditorHalfWidthTextInputMode | |
|
916 EAknEditorNumericInputMode ); |
|
917 } |
|
918 |
|
919 if ( iIsFindPopup ) |
|
920 { |
|
921 SetFindBoxVisibilityL( EFalse ); |
|
922 } |
|
923 |
|
924 } |
|
925 |
|
926 // ----------------------------------------------------------------------------- |
|
927 // Creates icon array, populates iIconArray to be used by listbox |
|
928 // ----------------------------------------------------------------------------- |
|
929 // |
|
930 void CMPXCommonContainerAvkonImp::CreateIconArrayL() |
|
931 { |
|
932 if ( iListBoxArray ) |
|
933 { |
|
934 iIconArray = iListBoxArray->CreateIconArrayL(); |
|
935 } |
|
936 } |
|
937 |
|
938 // End of File |