2 * Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Dialogs for selection service implementation.
19 #ifndef __AKNSELECTIONLIST_H__
20 #define __AKNSELECTIONLIST_H__
28 class CAknSelectionListDialogExtension;
29 class CAknMarkableListDialogExtension;
31 /** CAknSelectionListDialog is the actual interface to the applications.
33 * Use this class to get a full screen list.
35 * This class only works in whole main pane. Do not try to use
36 * this directly for other places.
41 * resource definition for this class:
43 * RESOURCE DIALOG r_res_id_for_a_dialog
45 * flags = EAknDialogSelectionList;
46 * buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK;
51 * type = EAknCtSingleGraphicListBox;
52 * id = ESelectionListControl;
55 * flags = EAknListBoxSelectionList;
58 * // the next dlg line is optional.
62 * itemflags = EEikDlgItemNonFocusing;
64 * type = EAknCtSelectionListFixedFind;
69 * The listbox type can be one of the following (defined in avkon.hrh and aknlists.h):
71 EAknCtSingleListBox (See CAknSingleStyleListBox)
72 EAknCtSingleNumberListBox (See CAknSingleNumberStyleListBox)
73 EAknCtSingleHeadingListBox (See CAknSingleHeadingStyleListBox)
74 EAknCtSingleGraphicListBox (See CAknSingleGraphicStyleListBox)
75 EAknCtSingleGraphicHeadingListBox (See CAknSingleGraphicHeadingStyleListBox)
76 EAknCtSingleNumberHeadingListBox (See CAknSingleNumberHeadingStyleListBox)
77 EAknCtSingleLargeListBox (See CAknSingleLargeStyleListBox)
78 EAknCtDoubleListBox (See CAknDoubleStyleListBox)
79 EAknCtDoubleNumberListBox (See CAknDoubleNumberStyleListBox)
80 EAknCtDoubleTimeListBox (See CAknDoubleTimeStyleListBox)
81 EAknCtDoubleLargeListBox (See CAknDoubleLargeStyleListBox)
82 EAknCtDoubleGraphicListBox (See CAknDoubleGraphicStyleListBox)
84 * The type field while defining find can be one of the following:
86 EAknCtSelectionListFixedFind
87 EAknCtSelectionListPopupFind
88 EAknCtSelectionListAdaptiveFind
91 * The menubar you give for selection list dialog should have
92 * one of the following as one of its menu panes (defined in avkon.hrh):
94 R_AVKON_MENUPANE_SELECTION_LIST
95 R_AVKON_MENUPANE_SELECTION_LIST_WITH_FIND_POPUP
98 * RESOURCE MENU_BAR r_res_id_for_a_menubar
102 * MENU_TITLE { menu_pane = R_AVKON_MENUPANE_SELECTION_LIST; }
108 * TInt openedItem = 0;
109 * MDesCArray *array = ...;
110 * CAknSelectionListDialog *dialog = CAknSelectionListDialog::NewL(openedItem, array, R_RES_ID_FOR_A_MENUBAR);
111 * TInt result = dialog->ExecuteLD(R_RES_ID_FOR_A_DIALOG);
114 * ...use openeditem here...
122 * Alternatively, you can use:
124 * TInt openedItem = 0;
125 * MDesCArray *array = ...;
126 * CAknSelectionListDialog *dialog = CAknSelectionListDialog::NewL(openedItem, array, R_RES_ID_FOR_A_MENUBAR);
127 * dialog->PrepareLC(R_RES_ID_FOR_A_DIALOG);
128 * // do some operations here, for example fill icon array
129 * TInt result = dialog->RunLD();
140 * Often it is also useful to derive from CAknSelectionListDialog and implement OkToExitL(), constructors and the NewL() methods.
141 * OkToExitL() implementation helps with providing navigation with other dialogs; OkToExitL() is ideal place to launch
142 * new dialogs when a list item is selected. This way when backstepping, the state of the first dialog is preserved...
146 class CAknSelectionListDialog : public CAknDialog, public MEikListBoxObserver
149 /** CAknSelectionListDialog::NewL()
151 * Static factory constructor. Uses two phase construction and leaves nothing on the CleanupStack.
153 * @param aOpenedItem Variable to be modified when user selects a list item.
154 * @param aArray Content of list items; A tab-separated string with texts and indexes to icon array
155 * @param aMenuBarResourceId Menu items to be shown in options menu
156 * @param aCommand Callback for state changes. EAknCmdOpen command is send by listbox. Options menu commands come here too.
157 * @return A pointer to created object
159 IMPORT_C static CAknSelectionListDialog *NewL( TInt &aOpenedItem, MDesCArray *aArray, TInt aMenuBarResourceId, MEikCommandObserver *aCommand = 0 );
161 /** CAknSelectionListDialog::NewLC()
163 * Static factory constructor. Uses two phase construction and leaves created object in CleanupStack.
165 * @param aOpenedItem Variable to be modified when user selects a list item.
166 * @param aArray Content of list items; A tab-separated string with texts and indexes to icon array
167 * @param aMenuBarResourceId Menu items to be shown in options menu
168 * @param aCommand Callback for state changes. EAknCmdOpen command is send by listbox. Options menu commands come here too.
169 * @return A pointer to created object
171 IMPORT_C static CAknSelectionListDialog *NewLC( TInt &aOpenedItem, MDesCArray *aArray, TInt aMenuBarResourceId, MEikCommandObserver *aCommand = 0 );
174 * Second phase constructor.
176 * @param aMenuTitleResourceId Menu items to be shown in options menu. Same as aMenuBarResourceId of NewL(C).
178 IMPORT_C void ConstructL(TInt aMenuTitleResourceId);
181 /** CAknSelectionListDialog::TFindType
182 * Determines what kind of findbox should be used. Note, that a fixed findbox is not
183 * available with all list types.
187 /** no findbox should be used */
189 /** fixed findbox should be used */
191 /** popup findbox should be used */
193 /** fixed findbox with adaptive search should be used */
199 * Provides a way to enable and disable find and find popup on runtime.
200 * You still need entry with id EFindControl to resource file for the find, this is only for disabling
201 * existing find element.
203 * @param aType type of findbox to be used.
205 IMPORT_C void SetupFind(TFindType aType);
209 * Icons, images and thumbnails are in this array.
211 * The list items are tab separated strings with fixed format. Some of the numbers
212 * in the list item strings are indexes to this array.
214 * This array can be modified by MDesCArray::MdcaPoint() method or at construction of
215 * dialog; after PrepareLC() call.
217 * @return pointer to iconarray of the list
219 IMPORT_C CArrayPtr<CGulIcon>* IconArray() const;
223 * Icons, images and thumbnails are in this array.
225 * The list items are tab separated strings with fixed format. Some of the numbers
226 * in the list item strings are indexes to this array.
228 * This array can be modified by MDesCArray::MdcaPoint() method or at construction of
229 * dialog; after PrepareLC() call.
231 * @param aIcons a array containing icons.
233 IMPORT_C void SetIconArrayL(CArrayPtr<CGulIcon>* aIcons);
237 * Handles pointer events
238 * @param aPointerEvent The pointer event.
240 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
243 /** CAknSelectionListDialog()
244 * Default constructor.
246 IMPORT_C CAknSelectionListDialog( TInt &aIndex, MDesCArray *aArray, MEikCommandObserver *aCommand );
247 /** ~CAknSelectionListDialog()
250 IMPORT_C ~CAknSelectionListDialog();
252 protected: // Customisation from derived classes
253 /** SelectionListProcessCommandL() handles selection list and markable list
256 * For markable lists, this method handles EAknCmdMark, EAknCmdUnmark, EAknMarkAll, EAknUnmarkAll
257 * defined in options menu pane R_AVKON_MENUPANE_MARKABLE_LIST.
259 IMPORT_C virtual void SelectionListProcessCommandL(TInt aCommand);
261 /** IsAcceptableListBoxType(): Detection of list and grid layouts
263 * The CAknSelectionList only works with certain list and grid
266 * You will get Panic() if you use your own list/grid layouts and
267 * you do not have this method implemented!
269 * If you add new list layouts, you should implement this method to
270 * publish the type of the layout using this method. This is especially
271 * the case where you use CAknSelectionGrid with your own grid layout.
272 * (as there are no predefined grid layouts, you need to do this
273 * every time you use a selection grid)
275 * The following aControlTypes are already implemented and requires
279 EAknCtSingleNumberListBox
280 EAknCtSingleHeadingListBox
281 EAknCtSingleGraphicListBox
282 EAknCtSingleGraphicHeadingListBox
283 EAknCtSingleNumberHeadingListBox
284 EAknCtSingleLargeListBox
286 EAknCtDoubleNumberListBox
287 EAknCtDoubleTimeListBox
288 EAknCtDoubleLargeListBox
289 EAknCtDoubleGraphicListBox
291 EAknCtSettingNumberListBox
294 * Any other layout requires you to inherit from CAknSelectionList
295 * and implement the following methods:
297 * TBool IsAcceptableListBoxType(TInt aControlType, TBool &aIsFormattedCellList)
299 * if (aControlType == EMyCtGridLayout)
301 * // CAknGrid is-a formattedcelllistbox.
302 * aIsFormattedCellList = ETrue;
312 * See also CreateCustomControlL(). IsAcceptableListBoxType() and CreateCustomControlL() forms a pair that should
313 * be implemented together.
315 * @param aControlType type of the control. Ignored in current default implementation.
316 * @param aIsFormattedCellList returns whetehr list is a formatted cell listbox or a column listbox.
317 * Ignored in current default implementation. In derived implementations this must be set according to
318 * dialog's listbox type.
319 * @return whether layout can be used
321 IMPORT_C virtual TBool IsAcceptableListBoxType(TInt aControlType, TBool &aIsFormattedCellList) const;
323 /** ProcessCommandL()
324 * From CAknDialog. Processes commands and passes commands to FindBox and ListBox as needed.
325 * @param aCommandId id of the command.
327 IMPORT_C void ProcessCommandL( TInt aCommandId );
329 /** PreLayoutDynInitL()
332 IMPORT_C void PreLayoutDynInitL();
334 /** PreLayoutDynInitL()
337 IMPORT_C void PostLayoutDynInitL();
339 /** SetSizeAndPosition()
341 * Sets dialog's size to whole main pane.
342 * @param aSize ignored
344 IMPORT_C void SetSizeAndPosition(const TSize &aSize);
348 * This is not called if the Cancel button is activated unless the EEikDialogFlagNotifyEsc flag has been set.
349 * @param aButtonId The ID of the button that was activated.
351 IMPORT_C TBool OkToExitL( TInt aButtonId );
353 /** HandleListBoxEventL()
354 * From MEikListBoxObserver
355 * Handles listbox events.
356 * @param aListBox currently ignored
357 * @param aEventType type of the listbox event
359 IMPORT_C void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType );
361 /** CountComponentControls()
364 IMPORT_C TInt CountComponentControls() const;
366 /** ComponentControl()
369 IMPORT_C CCoeControl* ComponentControl( TInt aIndex ) const;
374 IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
376 /** CreateCustomControlL() creates own list or grid layouts.
378 * Normal implementation of this method is:
381 * SEikControlInfo CreateCustomControlL(TInt aControlType)
383 * CCoeControl *control = NULL;
384 * if ( aControlType == EMyCtGridLayout )
386 * // CMyOddStyleGrid should be derived from CAknFormattedCellListBox or CEikColumnListBox.
387 * control = new(ELeave)CMyOddStyleGrid;
389 * SEikControlInfo info = {control,0,0};
393 * See also IsAcceptableListBoxType(). CreateCustomControlL() and IsAcceptableListBoxType() forms a pair that should
394 * be implemented together.
396 IMPORT_C SEikControlInfo CreateCustomControlL(TInt aControlType);
399 * accessor to listbox control
400 * @return a pointer to the listbox
402 IMPORT_C virtual CEikListBox *ListBox() const;
405 * accessor to findbox control
406 * @return a pointer to the findbox
408 IMPORT_C CAknSearchField *FindBox() const;
410 /** IsFormattedCellListBox()
411 * used to check whether listbox control is a CEikFormattedCellListBox or a CEikColumnListBox.
412 * If you derive from IsAcceptableListBoxType() you must take care of the aIsFormattedCellListParameter to
413 * make this method to work correctly.
414 * @return whether listbox control is a CEikFormattedCellListBox
416 IMPORT_C TBool IsFormattedCellListBox() const;
421 IMPORT_C void Draw(const TRect&) const;
426 IMPORT_C void* ExtensionInterface( TUid aInterface );
428 IMPORT_C virtual void CEikDialog_Reserved_1();
429 IMPORT_C virtual void CEikDialog_Reserved_2();
431 IMPORT_C virtual void CAknDialog_Reserved();
432 private: // new function
433 IMPORT_C virtual void CAknSelectionListDialog_Reserved();
435 /** iEnterKeyPressed Set as ETrue if EAknCmdOpen is handled in
436 * ProcessCommandL(). This will eventually cause OkToExitL() to
437 * be called with EAknSoftkeyOk as aButtonId.
439 TBool iEnterKeyPressed;
443 * Callback function to exit dialog after selecting something with
444 * tapping it. This prevents dialog to be destroyed before dialog
445 * page's handlepointereventl is fully completed.
446 * @param aSelectionList pointer to current CAknSelectionList
448 static TInt ExitViaIdle(TAny* aSelectionList );
450 CAknSelectionListDialogExtension *iExtension;
452 CAknSearchField *iFindBox;
456 MEikCommandObserver *iCmdObserver;
457 TInt iDialogResourceId;
461 /** CAknMarkableListDialog is an interface for applications
463 * The class provides a list with items markable with shift+selection_key.
465 * What this class does:
467 * 1) Setup listbox for markable list (resource file still needs to be correct for markable lists :)
469 * 2) Loading default bitmaps
471 * 3) Handles mark/unmark/mark all/unmark all and edit list options menu visibility
473 * 4) Handles mark/unmark/mark all/unmark all commands from options menu
480 * resource definition for this class:
482 * RESOURCE DIALOG r_res_id_for_a_dialog
484 * flags = EAknDialogMarkableList;
485 * buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK;
490 * type = EAknCtSingleGraphicListBox;
491 * id = ESelectionListControl;
494 * flags = EAknListBoxMarkableList;
497 * // the next dlg line is optional.
501 * itemflags = EEikDlgItemNonFocusing;
503 * type = EAknCtSelectionListFixedFind;
509 * The listbox type can be one of the following ( defined in avkon.hrh and aknlists.h ):
511 EAknCtSingleListBox (See CAknSingleStyleListBox)
512 EAknCtSingleNumberListBox (See CAknSingleNumberStyleListBox)
513 EAknCtSingleHeadingListBox (See CAknSingleHeadingStyleListBox)
514 EAknCtSingleGraphicListBox (See CAknSingleGraphicStyleListBox)
515 EAknCtSingleGraphicHeadingListBox (See CAknSingleGraphicHeadingStyleListBox)
516 EAknCtSingleNumberHeadingListBox (See CAknSingleNumberHeadingStyleListBox)
517 EAknCtSingleLargeListBox (See CAknSingleLargeStyleListBox)
518 EAknCtDoubleListBox (See CAknDoubleStyleListBox)
519 EAknCtDoubleNumberListBox (See CAknDoubleNumberStyleListBox)
520 EAknCtDoubleTimeListBox (See CAknDoubleTimeStyleListBox)
521 EAknCtDoubleLargeListBox (See CAknDoubleLargeStyleListBox)
522 EAknCtDoubleGraphicListBox (See CAknDoubleGraphicStyleListBox)
525 * The type field while defining find can be one of the following:
527 EAknCtSelectionListFixedFind
528 EAknCtSelectionListPopupFind
529 EAknCtSelectionListAdaptiveFind
532 * The menubar you give for markable list dialog should have
533 * one of the following as menu panes:
535 R_AVKON_MENUPANE_MARKABLE_LIST to get edit list menu
536 R_AVKON_MENUPANE_MARKABLE_LIST_WITH_FIND_POPUP to get find and edit list
540 * RESOURCE MENU_BAR r_res_id_for_a_menubar
544 * MENU_TITLE { menu_pane = R_AVKON_MENUPANE_MARKABLE_LIST; }
552 * TInt openedItem = 0;
553 * MDesCArray *arrayOfItems = ...;
554 * CArrayFix<TInt> *selectedItems = ...;
555 * CAknMarkableListDialog *dialog = CAknMarkableListDialog::NewL(openedItem, selectedItems, arrayOfItems, R_RES_ID_FOR_A_MENUBAR);
556 * TInt result = dialog->ExecuteLD(R_RES_ID_FOR_A_DIALOG);
568 class CAknMarkableListDialog : public CAknSelectionListDialog
571 /** CAknMarkableListDialog::NewL()
573 * Static factory constructor. Uses two phase construction.
575 * @param aOpenedItem Variable to be modified when user
576 * selects a list item.
577 * @param aSelectedItems array of selected items
578 * @param aArray Content of list items;
579 * A tab-separated string with texts and indexes to icon array
580 * @param aMenuBarResourceId Menu items to be shown in options menu. May be NULL.
581 * @param aOkMenuBarId Resource id of a menu bar. This menu bar is displayed,
582 * when there are marked items in the list
583 * and user presses selection ( OK ) key. May be NULL.
584 * @param aObserver Observer for the menu bar. May be NULL.
585 * @return A pointer to created object
587 IMPORT_C static CAknMarkableListDialog *NewL( TInt &aOpenedItem,
588 CArrayFix<TInt> *aSelectedItems,
590 TInt aMenuBarResourceId,
592 MEikCommandObserver *aObserver =0 );
594 /** CAknMarkableListDialog::NewL()
596 * Static factory constructor. Uses two phase construction.
597 * Leaves created object to cleanup stack.
599 * @param aOpenedItem Variable to be modified when user
600 * selects a list item.
601 * @param aSelectedItems array of selected items
602 * @param aArray Content of list items;
603 * A tab-separated string with texts and indexes to icon array
604 * @param aMenuBarResourceId Menu items to be shown in options menu. May be NULL.
605 * @param aOkMenuBarId Resource id of a menu bar. This menu bar is displayed,
606 * when there are marked items in the list
607 * and user presses selection ( OK ) key. May be NULL.
608 * @param aObserver Observer for the menu bar. May be NULL.
609 * @return A pointer to created object
611 IMPORT_C static CAknMarkableListDialog *NewLC( TInt &aOpenedItem,
612 CArrayFix<TInt> *aSelectedItems,
614 TInt aMenuBarResourceId,
616 MEikCommandObserver *aObserver =0 );
619 * 2nd phase constructor.
620 * @param aMenuTitleResourceId Menu items to be shown in options menu
622 IMPORT_C void ConstructL( TInt aMenuTitleResourceId );
624 /* ~CAknMarkableListDialog()
627 IMPORT_C ~CAknMarkableListDialog();
629 public: // From CCoeControl
630 /** HandlePointerEventL()
632 * @param aPointerEvent a pointer event.
634 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
637 /** CAknMarkableListDialog()
639 * Default constructor.
640 * @param aOpenedItem Variable to be modified when user
641 * selects a list item.
642 * @param aSelectedItems array of selected items
643 * @param aArray Content of list items;
644 * A tab-separated string with texts and indexes to icon array
645 * @param aMenuBarResourceId Menu items to be shown in options menu. May be NULL.
646 * @param aOkMenuBarResourceId Resource id of a menu bar. This menu bar is displayed,
647 * when there are marked items in the list
648 * and user presses selection ( OK ) key. May be NULL.
649 * @param aObserver Observer for the menu bar. May be NULL.
650 * @return A pointer to created object
652 IMPORT_C CAknMarkableListDialog( TInt &aOpenedItem,
653 CArrayFix<TInt> *aSelectedItems,
655 TInt aMenuBarResourceId,
656 TInt aOkMenuBarResourceId,
657 MEikCommandObserver *aObserver );
658 /** PreLayoutDynInitL()
661 IMPORT_C void PreLayoutDynInitL();
663 /** PreLayoutDynInitL()
666 IMPORT_C void PostLayoutDynInitL();
668 /** SelectionListProcessCommandL() handles selection list and markable list
671 * For markable lists, this method handles EAknCmdMark, EAknCmdUnmark, EAknMarkAll, EAknUnmarkAll
672 * defined in options menu pane R_AVKON_MENUPANE_MARKABLE_LIST.
674 IMPORT_C void SelectionListProcessCommandL(TInt aCommand);
676 /** ProcessCommandL()
677 * From CAknDialog. Processes commands and passes commands to FindBox and ListBox as needed.
678 * @param aCommand id of the command.
680 IMPORT_C void ProcessCommandL(TInt aCommand);
682 /** DynInitMenuPaneL()
683 * From MEikCommandObserver
684 * @param aResourceId resource id of the menu pane to be modified
685 * @param aMenuPane pointer to menu pane to be modified
687 IMPORT_C void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane *aMenuPane);
689 /** HandleListBoxEventL()
690 * From MEikListBoxObserver
691 * Handles listbox events.
692 * @param aListBox currently ignored
693 * @param aEventType type of the listbox event
695 IMPORT_C void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType );
700 IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
704 * This is not called if the Cancel button is activated unless the EEikDialogFlagNotifyEsc flag has been set.
705 * @param aButtonId The ID of the button that was activated.
707 IMPORT_C TBool OkToExitL(TInt aButtonId);
710 CArrayFix<TInt> *iSelectionIndexArray; // Not owned
714 * resource id of the menu bar
716 TInt iMenuBarResourceId;
719 * resource id of the OK menu bar
721 TInt iOkMenuBarResourceId;
723 public: // DEPRECATED METHODS, DO NOT USE
725 * @deprecated Do not use.
727 IMPORT_C static CAknMarkableListDialog *NewL(TInt &aOpenedItem, CArrayFix<TInt> *aSelectedItems,
728 MDesCArray *aArray, TInt aMenuBarResourceId, MEikCommandObserver *aObserver =0);
730 * @deprecated Do not use.
732 IMPORT_C static CAknMarkableListDialog *NewLC(TInt &aOpenedItem, CArrayFix<TInt> *aSelectedItems,
733 MDesCArray *aArray, TInt aMenuBarResourceId, MEikCommandObserver *aObserver =0);
734 protected: // DEPRECATED METHODS, DO NOT USE
735 /** CAknMarkableListDialog()
736 * @deprecated Do not use.
738 IMPORT_C CAknMarkableListDialog(TInt &aValue, CArrayFix<TInt> *aSelectedItems, MDesCArray *aArray, MEikCommandObserver *aObserver);
744 IMPORT_C void* ExtensionInterface( TUid aInterface );
746 IMPORT_C virtual void CEikDialog_Reserved_1();
747 IMPORT_C virtual void CEikDialog_Reserved_2();
749 IMPORT_C virtual void CAknDialog_Reserved();
751 IMPORT_C virtual void CAknSelectionListDialog_Reserved();
753 CAknMarkableListDialogExtension *iMarkableExtension;
759 typedef CAknSelectionListDialog CAknSelectionGridDialog;
760 typedef CAknMarkableListDialog CAknMarkableGridDialog;