|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "aknselectionlist.h" |
|
21 #include <aknsfld.h> |
|
22 #include <eikfrlbd.h> |
|
23 #include <eikclb.h> |
|
24 #include <eikclbd.h> |
|
25 #include <AknPanic.h> |
|
26 #include <eikcapc.h> |
|
27 #include <AknUtils.h> |
|
28 #include <AknIconArray.h> |
|
29 #include <aknappui.h> |
|
30 #include <avkon.mbg> |
|
31 #include "AknDebug.h" |
|
32 #include "akntrace.h" |
|
33 |
|
34 // LOCAL FUNCTION PROTOTYPES |
|
35 |
|
36 // ==================== EXTENSION CLASS ==================== |
|
37 NONSHARABLE_CLASS(CAknSelectionListDialogExtension) : public CBase |
|
38 { |
|
39 public: |
|
40 CAknSelectionListDialogExtension(); |
|
41 ~CAknSelectionListDialogExtension(); |
|
42 |
|
43 public: |
|
44 CIdle *iIdle; |
|
45 }; |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CAknSelectionListDialogExtension::CAknSelectionListDialogExtension() |
|
49 // |
|
50 // Constructor |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CAknSelectionListDialogExtension::CAknSelectionListDialogExtension() |
|
54 { |
|
55 iIdle = NULL; |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CAknSelectionListDialogExtension::~CAknSelectionListDialogExtension() |
|
60 // |
|
61 // Destructor |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CAknSelectionListDialogExtension::~CAknSelectionListDialogExtension() |
|
65 { |
|
66 delete iIdle; |
|
67 } |
|
68 |
|
69 // ==================== EXTENSION CLASS ==================== |
|
70 NONSHARABLE_CLASS(CAknMarkableListDialogExtension) : public CBase |
|
71 { |
|
72 public: |
|
73 CAknMarkableListDialogExtension(); |
|
74 ~CAknMarkableListDialogExtension(); |
|
75 |
|
76 public: |
|
77 CIdle *iIdle; |
|
78 }; |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CAknMarkableListDialogExtension::CAknMarkableListDialogExtension() |
|
82 // |
|
83 // Constructor |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 CAknMarkableListDialogExtension::CAknMarkableListDialogExtension() |
|
87 { |
|
88 iIdle = NULL; |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CAknMarkableListDialogExtension::~CAknMarkableListDialogExtension() |
|
93 // |
|
94 // Destructor |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 CAknMarkableListDialogExtension::~CAknMarkableListDialogExtension() |
|
98 { |
|
99 delete iIdle; |
|
100 } |
|
101 |
|
102 // ==================== LOCAL FUNCTIONS ==================== |
|
103 |
|
104 class CFindControl : public CCoeControl |
|
105 { |
|
106 public: |
|
107 CAknSearchField *iFind; |
|
108 ~CFindControl() { delete iFind; } |
|
109 void Draw(const TRect &) const |
|
110 { |
|
111 // this removes flicker from CEikDialog's Draw(). |
|
112 } |
|
113 void SizeChanged() |
|
114 { |
|
115 _AKNTRACE_FUNC_ENTER; |
|
116 TRect mainPane; |
|
117 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane ); |
|
118 |
|
119 TAknLayoutRect listRect; |
|
120 |
|
121 listRect.LayoutRect( mainPane, AknLayout::list_gen_pane(0) ); |
|
122 |
|
123 TRect r( listRect.Rect() ); |
|
124 iPosition = TPoint( r.iTl ); |
|
125 iSize.SetSize( r.Width(), r.Height() ); |
|
126 _AKNTRACE( "[%s][%s] size: w = %d, h = %d.", |
|
127 "CFindControl", __FUNCTION__, iSize.iWidth, iSize.iHeight ); |
|
128 _AKNTRACE_FUNC_EXIT; |
|
129 } |
|
130 |
|
131 TSize MinimumSize() |
|
132 { |
|
133 if ( iFind ) |
|
134 { |
|
135 if ( iFind->Size() != TSize( 0, 0 ) ) |
|
136 { |
|
137 return iFind->Size(); |
|
138 } |
|
139 } |
|
140 |
|
141 return iSize; |
|
142 } |
|
143 }; |
|
144 |
|
145 |
|
146 // ================= MEMBER FUNCTIONS ======================= |
|
147 |
|
148 // C++ default constructor can NOT contain any code, that |
|
149 // might leave. |
|
150 // |
|
151 |
|
152 EXPORT_C CAknSelectionListDialog* CAknSelectionListDialog::NewL(TInt &aValue, MDesCArray *aArray, TInt aMenuBarResourceId, MEikCommandObserver *aCommand) |
|
153 { |
|
154 _AKNTRACE( "[%s][%s] aValue = %d, aMenuBarResourceId = %d.", |
|
155 "CAknSelectionListDialog", __FUNCTION__, aValue, aMenuBarResourceId ); |
|
156 CAknSelectionListDialog *dialog = NewLC(aValue, aArray, aMenuBarResourceId, aCommand); |
|
157 CleanupStack::Pop(); |
|
158 return dialog; |
|
159 } |
|
160 |
|
161 EXPORT_C CAknMarkableListDialog* CAknMarkableListDialog::NewL(TInt &aValue, CArrayFix<TInt> *aSelectedItems, MDesCArray *aArray, TInt aMenuBarResourceId, TInt aOkMenuBarId, MEikCommandObserver *aCommand) |
|
162 { |
|
163 _AKNTRACE( "[%s][%s] aValue = %d, aMenuBarResourceId = %d, aOkMenuBarId = %d.", |
|
164 "CAknMarkableListDialog", __FUNCTION__, aValue, aMenuBarResourceId, aOkMenuBarId ); |
|
165 CAknMarkableListDialog *dialog = NewLC(aValue, aSelectedItems, aArray, aMenuBarResourceId, aOkMenuBarId, aCommand); |
|
166 CleanupStack::Pop(); |
|
167 return dialog; |
|
168 } |
|
169 |
|
170 EXPORT_C CAknSelectionListDialog *CAknSelectionListDialog::NewLC(TInt &aValue, MDesCArray *aArray, TInt aMenuBarResourceId, MEikCommandObserver *aCommand) |
|
171 { |
|
172 _AKNTRACE( "[%s][%s] aValue = %d, aMenuBarResourceId = %d.", |
|
173 "CAknSelectionListDialog", __FUNCTION__, aValue, aMenuBarResourceId ); |
|
174 CAknSelectionListDialog *dialog = new(ELeave)CAknSelectionListDialog(aValue,aArray, aCommand); |
|
175 CleanupStack::PushL(dialog); |
|
176 dialog->ConstructL(aMenuBarResourceId); |
|
177 return dialog; |
|
178 } |
|
179 |
|
180 EXPORT_C CAknMarkableListDialog *CAknMarkableListDialog::NewLC(TInt &aValue, CArrayFix<TInt> *aSelectedItems, MDesCArray *aArray, TInt aMenuBarResourceId, TInt aOkMenuBarId, MEikCommandObserver *aCommand) |
|
181 { |
|
182 _AKNTRACE( "[%s][%s] aValue = %d, aMenuBarResourceId = %d, aOkMenuBarId = %d.", |
|
183 "CAknMarkableListDialog", __FUNCTION__, aValue, aMenuBarResourceId, aOkMenuBarId ); |
|
184 CAknMarkableListDialog *dialog = new(ELeave)CAknMarkableListDialog(aValue,aSelectedItems, aArray, aMenuBarResourceId, aOkMenuBarId, aCommand); |
|
185 CleanupStack::PushL(dialog); |
|
186 dialog->ConstructL(aMenuBarResourceId); |
|
187 return dialog; |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // CAknSelectionListDialog::ConstructL() |
|
192 // |
|
193 // Constructs extension class |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 EXPORT_C void CAknSelectionListDialog::ConstructL(TInt aMenuTitleResourceId) |
|
197 { |
|
198 _AKNTRACE( "[%s][%s] aMenuTitleResourceId = %d.", |
|
199 "CAknSelectionListDialog", __FUNCTION__, aMenuTitleResourceId ); |
|
200 CAknDialog::ConstructL(aMenuTitleResourceId); |
|
201 iExtension = new (ELeave) CAknSelectionListDialogExtension; |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CAknMarkableListDialog::ConstructL() |
|
206 // |
|
207 // Constructs extension class |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 EXPORT_C void CAknMarkableListDialog::ConstructL(TInt aMenuTitleResourceId) |
|
211 { |
|
212 _AKNTRACE( "[%s][%s] aMenuTitleResourceId = %d.", |
|
213 "CAknMarkableListDialog", __FUNCTION__, aMenuTitleResourceId ); |
|
214 CAknDialog::ConstructL(aMenuTitleResourceId); |
|
215 iMarkableExtension = new (ELeave) CAknMarkableListDialogExtension; |
|
216 } |
|
217 |
|
218 EXPORT_C CAknSelectionListDialog::CAknSelectionListDialog(TInt &aIndex, MDesCArray *aArray, MEikCommandObserver *aCommand) |
|
219 : iEnterKeyPressed(EFalse), |
|
220 iSelectedItem(&aIndex), |
|
221 iArray(aArray), |
|
222 iCmdObserver(aCommand) |
|
223 { |
|
224 } |
|
225 |
|
226 EXPORT_C CAknMarkableListDialog::CAknMarkableListDialog(TInt &aIndex, CArrayFix<TInt> * aSelectedItems, MDesCArray *aArray, TInt aMenuBarResourceId, TInt aOkMenuBarResourceId, MEikCommandObserver *aCommand) |
|
227 : CAknSelectionListDialog(aIndex,aArray, aCommand), |
|
228 iSelectionIndexArray(aSelectedItems), |
|
229 iMenuBarResourceId(aMenuBarResourceId), |
|
230 iOkMenuBarResourceId(aOkMenuBarResourceId) |
|
231 { |
|
232 } |
|
233 |
|
234 EXPORT_C CAknSelectionListDialog::~CAknSelectionListDialog() |
|
235 { |
|
236 if (iAvkonAppUi) |
|
237 iAvkonAppUi->RemoveFromStack( this ); |
|
238 delete iExtension; |
|
239 } |
|
240 |
|
241 EXPORT_C CAknMarkableListDialog::~CAknMarkableListDialog() |
|
242 { |
|
243 delete iMarkableExtension; |
|
244 } |
|
245 |
|
246 EXPORT_C CCoeControl* CAknSelectionListDialog::ComponentControl(TInt aIndex) const |
|
247 { |
|
248 if (aIndex == CAknDialog::CountComponentControls() ) |
|
249 { |
|
250 return FindBox(); |
|
251 } |
|
252 return CAknDialog::ComponentControl(aIndex); |
|
253 } |
|
254 |
|
255 EXPORT_C TInt CAknSelectionListDialog::CountComponentControls() const |
|
256 { |
|
257 TInt newitems = 0; |
|
258 if (FindBox()) newitems++; |
|
259 return CAknDialog::CountComponentControls() + newitems; |
|
260 } |
|
261 |
|
262 EXPORT_C TBool CAknSelectionListDialog::OkToExitL(TInt aButtonId) |
|
263 { |
|
264 TBool b = CAknDialog::OkToExitL(aButtonId); |
|
265 *iSelectedItem = ListBox()->CurrentItemIndex(); |
|
266 if (FindBox()) |
|
267 { |
|
268 if (*iSelectedItem != -1) |
|
269 *iSelectedItem = STATIC_CAST(CAknFilteredTextListBoxModel*,ListBox()->Model())->Filter()->FilteredItemIndex(*iSelectedItem); |
|
270 } |
|
271 _AKNTRACE( "[%s][%s] return value = %d.", |
|
272 "CAknSelectionListDialog", __FUNCTION__, b ); |
|
273 return b; |
|
274 } |
|
275 |
|
276 EXPORT_C void CAknSelectionListDialog::Draw(const TRect &) const |
|
277 { |
|
278 // this removes flicker from CEikDialog's Draw(). |
|
279 } |
|
280 |
|
281 EXPORT_C void CAknSelectionListDialog::ProcessCommandL(TInt aCommand) |
|
282 { |
|
283 _AKNTRACE( "[%s][%s] aCommand = %d.", |
|
284 "CAknSelectionListDialog", __FUNCTION__, aCommand ); |
|
285 CAknDialog::ProcessCommandL(aCommand); |
|
286 if (FindBox() && iFindType == EPopupFind) |
|
287 { |
|
288 AknFind::HandleFindPopupProcessCommandL(aCommand, ListBox(), FindBox(), this); |
|
289 DrawNow(); |
|
290 } |
|
291 |
|
292 if (iCmdObserver) iCmdObserver->ProcessCommandL(aCommand); |
|
293 switch(aCommand) |
|
294 { |
|
295 case EAknCmdOpen: |
|
296 iEnterKeyPressed = ETrue; |
|
297 break; |
|
298 default: |
|
299 SelectionListProcessCommandL(aCommand); |
|
300 break; |
|
301 }; |
|
302 } |
|
303 |
|
304 EXPORT_C void CAknSelectionListDialog::SelectionListProcessCommandL(TInt aCommand) |
|
305 { |
|
306 _AKNTRACE( "[%s][%s] aCommand = %d.", |
|
307 "CAknSelectionListDialog", __FUNCTION__, aCommand ); |
|
308 AknSelectionService::HandleSelectionListProcessCommandL(aCommand, ListBox()); |
|
309 } |
|
310 |
|
311 EXPORT_C void CAknSelectionListDialog::HandleListBoxEventL( CEikListBox* /*aListBox*/, TListBoxEvent aEventType ) |
|
312 { |
|
313 _AKNTRACE( "[%s][%s] aEventType = %d.", |
|
314 "CAknSelectionListDialog", __FUNCTION__, aEventType ); |
|
315 switch(aEventType) |
|
316 { |
|
317 case EEventItemDoubleClicked: |
|
318 case EEventItemSingleClicked: |
|
319 { |
|
320 if ( AknLayoutUtils::PenEnabled() ) |
|
321 { |
|
322 delete iExtension->iIdle; |
|
323 iExtension->iIdle = NULL; |
|
324 iExtension->iIdle = CIdle::NewL(CActive::EPriorityIdle); |
|
325 if (iExtension->iIdle) |
|
326 { |
|
327 iExtension->iIdle->Start(TCallBack(ExitViaIdle,this)); |
|
328 } |
|
329 } |
|
330 else |
|
331 { |
|
332 ProcessCommandL(EAknCmdOpen); |
|
333 // Should do nothing after this - the dialog might be deleted.. |
|
334 } |
|
335 } |
|
336 break; |
|
337 case EEventEnterKeyPressed: |
|
338 { |
|
339 ProcessCommandL(EAknCmdOpen); |
|
340 // Should do nothing after this - the dialog might be deleted.. |
|
341 } |
|
342 break; |
|
343 default: |
|
344 break; |
|
345 }; |
|
346 } |
|
347 |
|
348 // ----------------------------------------------------------------------------- |
|
349 // CAknSelectionListDialog::ExitViaIdle() |
|
350 // |
|
351 // Callback function to exit dialog after selecting something with tapping it. |
|
352 // This prevents dialog to be destroyed before dialog page's handlepointereventl |
|
353 // is fully completed. |
|
354 // ----------------------------------------------------------------------------- |
|
355 // |
|
356 TInt CAknSelectionListDialog::ExitViaIdle(TAny* aSelectionList ) |
|
357 { |
|
358 _AKNTRACE( "[%s][%s] aSelectionList = 0x%x.", |
|
359 "CAknSelectionListDialog", __FUNCTION__, aSelectionList ); |
|
360 CAknSelectionListDialog *selectionListDlg = (CAknSelectionListDialog*) aSelectionList; |
|
361 TRAP_IGNORE(selectionListDlg->TryExitL(EAknSoftkeyOk)); |
|
362 return EFalse; |
|
363 } |
|
364 |
|
365 EXPORT_C TKeyResponse CAknSelectionListDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
366 TEventCode aType) |
|
367 { |
|
368 _AKNTRACE( "[%s][%s] aKeyEvent(iCode = %d, iScanCode = %d, iModifiers = %d, iRepeats = %d) aType = %d.", |
|
369 "CAknSelectionListDialog", __FUNCTION__, aKeyEvent.iCode, aKeyEvent.iScanCode, aKeyEvent.iModifiers, aKeyEvent.iRepeats, aType ); |
|
370 // must pass escape event to dialog - findbox and listbox "eat" escape events |
|
371 TKeyResponse res = EKeyWasNotConsumed; |
|
372 if ( aType == EEventKey && aKeyEvent.iCode == EKeyEscape ) |
|
373 { |
|
374 res = CAknDialog::OfferKeyEventL(aKeyEvent, aType); |
|
375 } |
|
376 |
|
377 if ( res == EKeyWasConsumed ) |
|
378 return res; |
|
379 |
|
380 TBool needRefresh = EFalse; |
|
381 res = AknFind::HandleFindOfferKeyEventL(aKeyEvent, aType, this, ListBox(), FindBox(), iFindType==EPopupFind, needRefresh); |
|
382 if (needRefresh && FindBox()) |
|
383 { |
|
384 if (iFindType == EPopupFind) |
|
385 { |
|
386 // AknFind::HandlePopupFindSizeChanged(Control(EFindControl), ListBox(), FindBox()); |
|
387 AknFind::HandlePopupFindSizeChanged(this, ListBox(), FindBox()); |
|
388 } |
|
389 else if ( iFindType == EFixedFind || iFindType == EAdaptiveFind ) |
|
390 { |
|
391 // AknFind::HandleFixedFindSizeChanged(Control(EFindControl),(CAknColumnListBox*)ListBox(), FindBox()); |
|
392 AknFind::HandleFixedFindSizeChanged(this,(CAknColumnListBox*)ListBox(), FindBox()); |
|
393 } |
|
394 DrawNow(); |
|
395 } |
|
396 if ( res == EKeyWasConsumed ) |
|
397 return res; |
|
398 // Give the events to listbox first! This is because otherwise all events do not go to the controls! |
|
399 // Dialogs filter out KeyUp/KeyDown events. If we do not do this, marking is broken; Sometimes it does |
|
400 // not mark list items correctly. |
|
401 if (aKeyEvent.iCode == EKeyLeftArrow || aKeyEvent.iCode == EKeyRightArrow) |
|
402 { |
|
403 // Multipage dialogs need the left/right keys |
|
404 res = CAknDialog::OfferKeyEventL(aKeyEvent, aType); |
|
405 } |
|
406 else |
|
407 res = ListBox()->OfferKeyEventL(aKeyEvent, aType); |
|
408 if ( res == EKeyWasNotConsumed ) |
|
409 { |
|
410 res = CAknDialog::OfferKeyEventL(aKeyEvent, aType); |
|
411 } |
|
412 else |
|
413 { |
|
414 } |
|
415 if (iEnterKeyPressed) |
|
416 TryExitL(EAknSoftkeyOk); |
|
417 // should do nothing after this. |
|
418 return res; |
|
419 } |
|
420 |
|
421 EXPORT_C CEikListBox *CAknSelectionListDialog::ListBox() const |
|
422 { |
|
423 return (CEikListBox*)Control(ESelectionListControl); |
|
424 } |
|
425 |
|
426 EXPORT_C CAknSearchField *CAknSelectionListDialog::FindBox() const |
|
427 { |
|
428 CFindControl *control = (CFindControl*)ControlOrNull(EFindControl); |
|
429 if (control) { return control->iFind; } |
|
430 return NULL; |
|
431 } |
|
432 |
|
433 EXPORT_C void CAknSelectionListDialog::SetupFind(TFindType aType) |
|
434 { |
|
435 _AKNTRACE( "[%s][%s] aType = %d.", |
|
436 "CAknSelectionListDialog", __FUNCTION__, aType ); |
|
437 iFindType = aType; |
|
438 } |
|
439 |
|
440 EXPORT_C TBool CAknSelectionListDialog::IsAcceptableListBoxType(TInt /*aControlType*/, TBool &/*aIsFormattedCellListBox*/) const |
|
441 { |
|
442 return EFalse; |
|
443 } |
|
444 |
|
445 EXPORT_C TBool CAknSelectionListDialog::IsFormattedCellListBox() const |
|
446 { |
|
447 CEikCaptionedControl *line = Line(ESelectionListControl); |
|
448 TInt controlType = line->iControlType; |
|
449 TBool result = EFalse; |
|
450 if (IsAcceptableListBoxType(controlType, result)) |
|
451 return result; |
|
452 |
|
453 switch(controlType) |
|
454 { |
|
455 case EAknCtSingleListBox: |
|
456 case EAknCtSingleNumberListBox: |
|
457 case EAknCtSingleHeadingListBox: |
|
458 case EAknCtSingleGraphicListBox: |
|
459 case EAknCtSingleGraphicHeadingListBox: |
|
460 case EAknCtSingleNumberHeadingListBox: |
|
461 case EAknCtSingleLargeListBox: |
|
462 return EFalse; |
|
463 case EAknCtDoubleListBox: |
|
464 case EAknCtDoubleNumberListBox: |
|
465 case EAknCtDoubleTimeListBox: |
|
466 case EAknCtDoubleLargeListBox: |
|
467 case EAknCtDoubleGraphicListBox: |
|
468 case EAknCtSettingListBox: |
|
469 case EAknCtSettingNumberListBox: |
|
470 return ETrue; |
|
471 default: |
|
472 // If you hit this assert, you should derive from this dialog and |
|
473 // implement IsAcceptableListBoxType() method. |
|
474 __ASSERT_DEBUG(0, Panic(EAknPanicNotSupported)); |
|
475 return ETrue; |
|
476 } |
|
477 } |
|
478 |
|
479 EXPORT_C CArrayPtr<CGulIcon>* CAknSelectionListDialog::IconArray() const |
|
480 { |
|
481 if (IsFormattedCellListBox()) |
|
482 { |
|
483 return ((CEikFormattedCellListBox*)ListBox())->ItemDrawer()->FormattedCellData()->IconArray(); |
|
484 } |
|
485 else |
|
486 { |
|
487 return ((CEikColumnListBox*)ListBox())->ItemDrawer()->ColumnData()->IconArray(); |
|
488 } |
|
489 } |
|
490 |
|
491 EXPORT_C void CAknSelectionListDialog::SetIconArrayL(CArrayPtr<CGulIcon>* aIcons) |
|
492 { |
|
493 CArrayPtr<CGulIcon>* oldicons = IconArray(); |
|
494 if (oldicons) |
|
495 { |
|
496 oldicons->ResetAndDestroy(); |
|
497 delete oldicons; |
|
498 } |
|
499 |
|
500 if (IsFormattedCellListBox()) |
|
501 { |
|
502 ((CEikFormattedCellListBox*)ListBox())->ItemDrawer()->FormattedCellData()->SetIconArray(aIcons); |
|
503 } |
|
504 else |
|
505 { |
|
506 ((CEikColumnListBox*)ListBox())->ItemDrawer()->ColumnData()->SetIconArray(aIcons); |
|
507 } |
|
508 |
|
509 } |
|
510 |
|
511 EXPORT_C SEikControlInfo CAknSelectionListDialog::CreateCustomControlL(TInt aControlType) |
|
512 { |
|
513 _AKNTRACE( "[%s][%s] aControlType = %d.", |
|
514 "CAknSelectionListDialog", __FUNCTION__, aControlType ); |
|
515 CFindControl *control1= NULL; |
|
516 TBool findControl = EFalse; |
|
517 if (aControlType == EAknCtSelectionListFixedFind) |
|
518 { |
|
519 iFindType = EFixedFind; |
|
520 findControl = ETrue; |
|
521 } |
|
522 if (aControlType == EAknCtSelectionListPopupFind) |
|
523 { |
|
524 iFindType = EPopupFind; |
|
525 findControl = ETrue; |
|
526 } |
|
527 if (aControlType == EAknCtSelectionListAdaptiveFind) |
|
528 { |
|
529 iFindType = EAdaptiveFind; |
|
530 findControl = ETrue; |
|
531 } |
|
532 if (findControl) |
|
533 { |
|
534 control1 = new (ELeave) CFindControl; |
|
535 } |
|
536 SEikControlInfo info; |
|
537 info.iControl = control1; |
|
538 info.iFlags = 0; |
|
539 info.iTrailerTextId = 0; |
|
540 return info; |
|
541 } |
|
542 |
|
543 EXPORT_C void CAknSelectionListDialog::PreLayoutDynInitL() |
|
544 { |
|
545 _AKNTRACE_FUNC_ENTER; |
|
546 CEikCaptionedControl *line = Line(ESelectionListControl); |
|
547 TInt controlType = line->iControlType; |
|
548 switch(controlType) |
|
549 { |
|
550 case EAknCtSingleNumberListBox: |
|
551 case EAknCtSingleGraphicListBox: |
|
552 break; |
|
553 default: |
|
554 // Only 2 different list layouts are available for fixed find. |
|
555 // => if other layouts are used, turn the find to popup find |
|
556 // automatically. |
|
557 if ( iFindType == EFixedFind || iFindType == EAdaptiveFind ) |
|
558 { |
|
559 iFindType = EPopupFind; |
|
560 } |
|
561 }; |
|
562 |
|
563 CFindControl *control1 = (CFindControl*)ControlOrNull(EFindControl); |
|
564 CAknSearchField *control = NULL; |
|
565 CAknSearchField::TSearchFieldStyle flags = CAknSearchField::EFixed; |
|
566 if (control1) |
|
567 { |
|
568 if (iFindType == EPopupFind) |
|
569 flags = CAknSearchField::EPopup; |
|
570 if (iFindType == EFixedFind) |
|
571 flags = CAknSearchField::EFixed; |
|
572 if (iFindType == EAdaptiveFind) |
|
573 flags = CAknSearchField::EAdaptive; |
|
574 control = CAknSearchField::NewL( *control1, flags, 0, 40 ); |
|
575 control1->iFind = control; |
|
576 } |
|
577 |
|
578 CAknDialog::PreLayoutDynInitL(); |
|
579 iAvkonAppUi->AddToStackL(this); |
|
580 |
|
581 CEikListBox *listbox = ListBox(); |
|
582 CEikTextListBox *txtlistbox = (CEikTextListBox*)listbox; |
|
583 |
|
584 // Listbox items |
|
585 if (iArray) |
|
586 { |
|
587 txtlistbox -> Model() -> SetItemTextArray( iArray ); |
|
588 txtlistbox -> Model() -> SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
589 } |
|
590 |
|
591 // Scrollbar |
|
592 listbox->CreateScrollBarFrameL(ETrue); |
|
593 listbox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); |
|
594 |
|
595 // Listbox observer |
|
596 listbox->SetListBoxObserver(this); |
|
597 |
|
598 |
|
599 if (FindBox()) |
|
600 { |
|
601 if (iFindType == EPopupFind) |
|
602 { |
|
603 STATIC_CAST(CAknFilteredTextListBoxModel*,ListBox()->Model())->CreateFilterL(ListBox(),FindBox()); |
|
604 } |
|
605 else if ( iFindType == EFixedFind || iFindType == EAdaptiveFind ) |
|
606 { |
|
607 // Fixed find is only available with list_single_graphic_pane |
|
608 __ASSERT_DEBUG(!IsFormattedCellListBox(), Panic(EAknPanicOutOfRange)); |
|
609 STATIC_CAST(CAknFilteredTextListBoxModel*,ListBox()->Model())->CreateFilterL(ListBox(),FindBox()); |
|
610 |
|
611 } |
|
612 } |
|
613 _AKNTRACE_FUNC_EXIT; |
|
614 } |
|
615 |
|
616 |
|
617 EXPORT_C void CAknSelectionListDialog::SetSizeAndPosition(const TSize &/*aSize*/) |
|
618 { |
|
619 TRect mainPane; |
|
620 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane ); |
|
621 _AKNTRACE( "[%s][%s] mainPane(l = %d, t = %d, r = %d, b = %d).", |
|
622 "CAknSelectionListDialog", __FUNCTION__, mainPane.iTl.iX, mainPane.iTl.iY,\ |
|
623 mainPane.iBr.iX, mainPane.iBr.iY ); |
|
624 SetRect( mainPane ); |
|
625 |
|
626 if (FindBox()) |
|
627 { |
|
628 if (iFindType == EPopupFind) |
|
629 { |
|
630 TBool findPaneVisible = FindBox()->IsFocused(); |
|
631 FindBox()->MakeVisible( findPaneVisible ); |
|
632 AknFind::HandlePopupFindSizeChanged( this, ListBox(), FindBox() ); |
|
633 } |
|
634 else if ( iFindType == EFixedFind || iFindType == EAdaptiveFind ) |
|
635 { |
|
636 AknFind::HandleFixedFindSizeChanged( this,(CAknColumnListBox*)ListBox(), FindBox()); |
|
637 } |
|
638 } |
|
639 } |
|
640 |
|
641 EXPORT_C void CAknSelectionListDialog::PostLayoutDynInitL() |
|
642 { |
|
643 _AKNTRACE_FUNC_ENTER; |
|
644 CAknDialog::PostLayoutDynInitL(); |
|
645 _AKNTRACE_FUNC_EXIT; |
|
646 } |
|
647 |
|
648 EXPORT_C void CAknSelectionListDialog::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
649 { |
|
650 _AKNTRACE( "[%s][%s] aPointerEvent(iType = %d, iModifiers = %d, iPosition(iX = %d, iY = %d), iParentPosition(iX = %d, iY = %d)).", |
|
651 "CAknSelectionListDialog", __FUNCTION__, aPointerEvent.iType, aPointerEvent.iModifiers, \ |
|
652 aPointerEvent.iPosition.iX, aPointerEvent.iPosition.iY, aPointerEvent.iParentPosition.iX, aPointerEvent.iParentPosition.iY ); |
|
653 CAknDialog::HandlePointerEventL(aPointerEvent); |
|
654 } |
|
655 |
|
656 EXPORT_C void* CAknSelectionListDialog::ExtensionInterface( TUid /*aInterface*/ ) |
|
657 { |
|
658 return NULL; |
|
659 } |
|
660 |
|
661 EXPORT_C void CAknSelectionListDialog::CEikDialog_Reserved_1() |
|
662 { |
|
663 } |
|
664 |
|
665 EXPORT_C void CAknMarkableListDialog::CEikDialog_Reserved_1() |
|
666 { |
|
667 } |
|
668 |
|
669 EXPORT_C void CAknSelectionListDialog::CEikDialog_Reserved_2() |
|
670 { |
|
671 } |
|
672 |
|
673 EXPORT_C void CAknMarkableListDialog::CEikDialog_Reserved_2() |
|
674 { |
|
675 } |
|
676 |
|
677 EXPORT_C void CAknSelectionListDialog::CAknDialog_Reserved() |
|
678 { |
|
679 } |
|
680 |
|
681 EXPORT_C void CAknMarkableListDialog::CAknDialog_Reserved() |
|
682 { |
|
683 } |
|
684 |
|
685 EXPORT_C void CAknSelectionListDialog::CAknSelectionListDialog_Reserved() |
|
686 { |
|
687 } |
|
688 |
|
689 EXPORT_C void CAknMarkableListDialog::CAknSelectionListDialog_Reserved() |
|
690 { |
|
691 } |
|
692 |
|
693 |
|
694 EXPORT_C void CAknMarkableListDialog::HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType ) |
|
695 { |
|
696 _AKNTRACE( "[%s][%s] aListBox = 0x%x, aEventType = %d.", |
|
697 "CAknMarkableListDialog", __FUNCTION__, aListBox, aEventType ); |
|
698 if ( AknLayoutUtils::PenEnabled() ) |
|
699 { |
|
700 switch(aEventType) |
|
701 { |
|
702 case EEventEnterKeyPressed: |
|
703 { |
|
704 /* Do nothing -- offerkeyevent handles this */ |
|
705 } |
|
706 break; |
|
707 case EEventItemClicked: |
|
708 { |
|
709 const CListBoxView::CSelectionIndexArray *selections = aListBox->SelectionIndexes(); |
|
710 |
|
711 // if current item is only selected item and control or shift is not pressed same time, |
|
712 // then select tapped index. |
|
713 if ( aListBox->View()->ItemIsSelected( aListBox->View()->CurrentItemIndex() ) && |
|
714 selections->Count() == 1 && |
|
715 !((aListBox->EventModifiers() & EModifierCtrl) || |
|
716 (aListBox->EventModifiers() & EModifierShift)) ) |
|
717 { |
|
718 // Close dialog via idle object. |
|
719 delete iMarkableExtension->iIdle; |
|
720 iMarkableExtension->iIdle = NULL; |
|
721 iMarkableExtension->iIdle = CIdle::NewL(CActive::EPriorityIdle); |
|
722 if (iMarkableExtension->iIdle) |
|
723 { |
|
724 iMarkableExtension->iIdle->Start(TCallBack(ExitViaIdle,this)); |
|
725 } |
|
726 } |
|
727 } |
|
728 default: |
|
729 break; |
|
730 }; |
|
731 } |
|
732 else |
|
733 { |
|
734 switch(aEventType) |
|
735 { |
|
736 case EEventEnterKeyPressed: |
|
737 case EEventItemDoubleClicked: |
|
738 { |
|
739 /* Do nothing -- offerkeyevent handles this */ |
|
740 } |
|
741 break; |
|
742 default: |
|
743 break; |
|
744 } |
|
745 } |
|
746 } |
|
747 |
|
748 |
|
749 EXPORT_C void CAknMarkableListDialog::SelectionListProcessCommandL(TInt aCommand) |
|
750 { |
|
751 _AKNTRACE( "[%s][%s] aCommand = %d.", "CAknMarkableListDialog", __FUNCTION__, aCommand ); |
|
752 AknSelectionService::HandleMarkableListProcessCommandL( aCommand, ListBox() ); |
|
753 } |
|
754 |
|
755 EXPORT_C void CAknMarkableListDialog::ProcessCommandL(TInt aCommand) |
|
756 { |
|
757 _AKNTRACE( "[%s][%s] aCommand = %d.", "CAknMarkableListDialog", __FUNCTION__, aCommand ); |
|
758 CAknSelectionListDialog::ProcessCommandL( aCommand ); |
|
759 } |
|
760 |
|
761 EXPORT_C TBool CAknMarkableListDialog::OkToExitL(TInt aButtonId) |
|
762 { |
|
763 TBool b = CAknSelectionListDialog::OkToExitL(aButtonId); |
|
764 if (iSelectionIndexArray) |
|
765 { |
|
766 const CArrayFix<TInt> *array = ListBox()->SelectionIndexes(); |
|
767 if (FindBox()) |
|
768 { |
|
769 STATIC_CAST(CAknFilteredTextListBoxModel*,ListBox()->Model())->Filter()->UpdateSelectionIndexesL(); |
|
770 array = STATIC_CAST(CAknFilteredTextListBoxModel*,ListBox()->Model())->Filter()->SelectionIndexes(); |
|
771 } |
|
772 TInt numberOfItems(array->Count()); |
|
773 iSelectionIndexArray->Reset(); |
|
774 for(TInt i(0); i<numberOfItems; i++) |
|
775 iSelectionIndexArray->AppendL(array->At(i)); |
|
776 } |
|
777 _AKNTRACE( "[%s][%s] return value = %d.", "CAknMarkableListDialog", __FUNCTION__, b ); |
|
778 return b; |
|
779 } |
|
780 |
|
781 |
|
782 EXPORT_C void CAknMarkableListDialog::PreLayoutDynInitL() |
|
783 { |
|
784 _AKNTRACE_FUNC_ENTER; |
|
785 CAknSelectionListDialog::PreLayoutDynInitL(); |
|
786 _AKNTRACE_FUNC_EXIT; |
|
787 } |
|
788 |
|
789 EXPORT_C void CAknMarkableListDialog::PostLayoutDynInitL() |
|
790 { |
|
791 _AKNTRACE_FUNC_ENTER; |
|
792 CAknSelectionListDialog::PostLayoutDynInitL(); |
|
793 |
|
794 // Check if we need default icons |
|
795 TBool iconsNeeded = EFalse; |
|
796 if ( IsFormattedCellListBox() ) |
|
797 { |
|
798 CFormattedCellListBoxData *boxData = ((CEikFormattedCellListBox*)ListBox())->ItemDrawer()->FormattedCellData(); |
|
799 if ( ! boxData->IconArray() ) iconsNeeded = ETrue; |
|
800 } |
|
801 else |
|
802 { |
|
803 CColumnListBoxData *boxData = ((CEikColumnListBox*)ListBox())->ItemDrawer()->ColumnData(); |
|
804 if ( ! boxData->IconArray() ) iconsNeeded = ETrue; |
|
805 } |
|
806 |
|
807 // loading default bitmaps |
|
808 if ( iconsNeeded ) |
|
809 { |
|
810 CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(4); |
|
811 CleanupStack::PushL( icons ); |
|
812 CGulIcon* icon = CGulIcon::NewLC(); |
|
813 CFbsBitmap* bitmap; |
|
814 CFbsBitmap* mask; |
|
815 |
|
816 MAknsSkinInstance *skin = AknsUtils::SkinInstance(); |
|
817 |
|
818 AknsUtils::CreateIconL( skin, |
|
819 KAknsIIDQgnIndiMarkedAdd, |
|
820 bitmap, |
|
821 mask, |
|
822 AknIconUtils::AvkonIconFileName(), |
|
823 EMbmAvkonQgn_indi_marked_add, |
|
824 EMbmAvkonQgn_indi_marked_add_mask ); |
|
825 |
|
826 icon->SetBitmap( bitmap ); |
|
827 icon->SetMask( mask ); |
|
828 |
|
829 icons->AppendL(icon); |
|
830 CleanupStack::Pop(); // icon |
|
831 |
|
832 if ( IsFormattedCellListBox() ) |
|
833 { |
|
834 CFormattedCellListBoxData *boxData = ((CEikFormattedCellListBox*)ListBox())->ItemDrawer()->FormattedCellData(); |
|
835 boxData->SetIconArray( icons ); |
|
836 } |
|
837 else |
|
838 { |
|
839 CColumnListBoxData *boxData = ((CEikColumnListBox*)ListBox())->ItemDrawer()->ColumnData(); |
|
840 boxData->SetIconArray( icons ); |
|
841 } |
|
842 CleanupStack::Pop(); // icons |
|
843 } |
|
844 |
|
845 CEikListBox *listbox = ListBox(); |
|
846 // final listbox setup |
|
847 listbox -> ActivateL (); |
|
848 |
|
849 // Initial highlight position |
|
850 listbox -> SetCurrentItemIndex (0); |
|
851 |
|
852 _AKNTRACE_FUNC_EXIT; |
|
853 } |
|
854 |
|
855 EXPORT_C void CAknMarkableListDialog::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane *aMenuPane) |
|
856 { |
|
857 _AKNTRACE( "[%s][%s] aResourceId = %d.", "CAknMarkableListDialog", __FUNCTION__, aResourceId ); |
|
858 AknSelectionService::HandleMarkableListDynInitMenuPane(aResourceId, aMenuPane, ListBox()); |
|
859 CAknSelectionListDialog::DynInitMenuPaneL(aResourceId, aMenuPane); |
|
860 } |
|
861 |
|
862 EXPORT_C TKeyResponse CAknMarkableListDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
863 TEventCode aType) |
|
864 { |
|
865 _AKNTRACE( "[%s][%s] aKeyEvent(iCode = %d, iScanCode = %d, iModifiers = %d, iRepeats = %d) aType = %d.", |
|
866 "CAknMarkableListDialog", __FUNCTION__, aKeyEvent.iCode, aKeyEvent.iScanCode, aKeyEvent.iModifiers, aKeyEvent.iRepeats, aType ); |
|
867 TKeyResponse retval = EKeyWasNotConsumed; |
|
868 |
|
869 TBool shiftKeyPressed = (aKeyEvent.iModifiers & EModifierShift); |
|
870 if (aKeyEvent.iCode == EKeyOK && aType == EEventKey |
|
871 && !shiftKeyPressed && iOkMenuBarResourceId && ListBox()->SelectionIndexes()->Count() > 0) |
|
872 { |
|
873 iMenuBar->SetMenuTitleResourceId( iOkMenuBarResourceId ); |
|
874 // This must be trapped so that menubar will be restored on leave |
|
875 TRAP_IGNORE(iMenuBar->TryDisplayMenuBarL( ) ); |
|
876 iEikonEnv->EikAppUi( )->HandleStackChanged( ); |
|
877 iMenuBar->SetMenuTitleResourceId( iMenuBarResourceId ); |
|
878 retval = EKeyWasConsumed; |
|
879 } |
|
880 else |
|
881 { |
|
882 retval = CAknSelectionListDialog::OfferKeyEventL(aKeyEvent, aType); |
|
883 } |
|
884 return retval; |
|
885 } |
|
886 |
|
887 EXPORT_C void CAknMarkableListDialog::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
888 { |
|
889 _AKNTRACE( "[%s][%s] aPointerEvent(iType = %d, iModifiers = %d, iPosition(iX = %d, iY = %d), iParentPosition(iX = %d, iY = %d)).", |
|
890 "CAknMarkableListDialog", __FUNCTION__, aPointerEvent.iType, aPointerEvent.iModifiers, \ |
|
891 aPointerEvent.iPosition.iX, aPointerEvent.iPosition.iY, aPointerEvent.iParentPosition.iX, aPointerEvent.iParentPosition.iY ); |
|
892 CAknSelectionListDialog::HandlePointerEventL(aPointerEvent); |
|
893 } |
|
894 |
|
895 EXPORT_C void* CAknMarkableListDialog::ExtensionInterface( TUid /*aInterface*/ ) |
|
896 { |
|
897 return NULL; |
|
898 } |
|
899 |
|
900 // |
|
901 // DEPRECATED METHODS, DO NOT USE THESE |
|
902 // |
|
903 EXPORT_C CAknMarkableListDialog* CAknMarkableListDialog::NewL(TInt &aValue, CArrayFix<TInt> *aSelectedItems, MDesCArray *aArray, TInt aMenuBarResourceId, MEikCommandObserver *aCommand) |
|
904 { |
|
905 #ifdef AVKON_RDEBUG_INFO |
|
906 RDebug::Print(_L("CAknMarkableListDialog::NewL is deprecated, please do not use it!")); |
|
907 #endif |
|
908 CAknMarkableListDialog *dialog = NewLC(aValue, aSelectedItems, aArray, aMenuBarResourceId, NULL, aCommand); |
|
909 CleanupStack::Pop(); |
|
910 return dialog; |
|
911 } |
|
912 |
|
913 // |
|
914 // DEPRECATED METHODS, DO NOT USE THESE |
|
915 // |
|
916 EXPORT_C CAknMarkableListDialog *CAknMarkableListDialog::NewLC(TInt &aValue, CArrayFix<TInt> *aSelectedItems, MDesCArray *aArray, TInt aMenuBarResourceId, MEikCommandObserver *aCommand) |
|
917 { |
|
918 #ifdef AVKON_RDEBUG_INFO |
|
919 RDebug::Print(_L("CAknMarkableListDialog::NewLC() is deprecated, please do not use it!")); |
|
920 #endif |
|
921 CAknMarkableListDialog *dialog = new(ELeave)CAknMarkableListDialog(aValue,aSelectedItems, aArray, aMenuBarResourceId, NULL, aCommand); |
|
922 CleanupStack::PushL(dialog); |
|
923 dialog->ConstructL(aMenuBarResourceId); |
|
924 return dialog; |
|
925 } |
|
926 |
|
927 // |
|
928 // DEPRECATED METHODS, DO NOT USE THESE |
|
929 // |
|
930 EXPORT_C CAknMarkableListDialog::CAknMarkableListDialog(TInt &aIndex, CArrayFix<TInt> * aSelectedItems, MDesCArray *aArray, MEikCommandObserver *aCommand) |
|
931 : CAknSelectionListDialog(aIndex,aArray, aCommand), |
|
932 iSelectionIndexArray(aSelectedItems), |
|
933 iMenuBarResourceId(NULL), |
|
934 iOkMenuBarResourceId(NULL) |
|
935 { |
|
936 #ifdef AVKON_RDEBUG_INFO |
|
937 RDebug::Print(_L("CAknMarkableListDialog::CAknMarkableListDialog is deprecated, please do not use it!")); |
|
938 #endif |
|
939 } |
|
940 |
|
941 // End of File |
|
942 |
|
943 |
|
944 |