2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Support for Avkon Popped-up lists
21 #if !defined(__AKNPOPUP_H__)
22 #define __AKNPOPUP_H__
27 #include <aknpopuplayout.h>
28 #include <aknintermediate.h>
29 #include <aknpopupfader.h>
31 class CAknPopupHeadingPane;
32 class CEikButtonGroupContainer;
34 class CAknSearchField;
35 class CAknPopupListExtension;
37 /** Used to popup a list or grid. Takes an existing listbox control and
38 * puts it into a popup frame together with an optional title.
40 * @c CAknPopupList is not a dialog!
42 * There are two standard usages of @c CAknPopupList:
45 * CAknPopupList *plist = CAknPopupList::NewL(...);
46 * CleanupStack::PushL(plist);
48 * TInt popupOk = plist->ExecuteLD(...);
49 * // No leaving functions allowed between ExecuteLD and
50 * // CleanupStack::Pop().
51 * CleanupStack::Pop(); // plist
52 * if (popupOk) { ... } else { ... }
55 * And then another way:
57 * iPList = CAknPopupList::NewL(...);
59 * TInt popupOk = iPlist->ExecuteLD(...);
60 * // No leaving functions allowed between ExecuteLD and iPlist=NULL;
62 * if (popupOk) {... } else {... }
63 * // note, destructor deletes the iPlist instance.
66 * Both these work corretly and leave-safe way. Notice this usage is pretty
67 * different of how dialogs work. With dialogs you _always_ want to do
68 * @c CleanupStack::Pop() before calling @c ExecuteLD().
70 class CAknPopupList : public CEikBorderedControl,
71 public MEikCommandObserver,
72 public MEikListBoxObserver,
73 public MCoeControlObserver,
74 public MAknIntermediateState,
75 public MAknFadedComponent
79 DECLARE_TYPE_ID(0x20018439)
84 * Two-phased constructor.
86 * Creates the pop-up list.
88 * @param aListBox Pre-existing listbox-derived class.
89 * @param aCbaResource Softkey pane to display while pop-up is active.
90 * @param aType The layout used.
91 * @return A pointer to a pop-up list object.
93 IMPORT_C static CAknPopupList* NewL(
94 CEikListBox* aListBox,
96 AknPopupLayouts::TAknPopupLayouts aType = AknPopupLayouts::EMenuWindow);
99 * Executes the pop-up selection list. Function returns when the user have
100 * accepted or cancelled the pop-up.
102 * @return @c ETrue if the popup was accepted. @c EFalse if
103 * the popup was cancelled.
105 IMPORT_C TBool ExecuteLD();
108 * Sets the title for the selection list.
110 * @param aTitle Title to be displayed.
112 IMPORT_C void SetTitleL(const TDesC& aTitle);
115 * Cancels the current popup. The popup @c ExecuteLD will return with
118 IMPORT_C void CancelPopup();
119 public: // Access methods
122 * Gets a button group container.
124 * @return The button group.
126 IMPORT_C CEikButtonGroupContainer* ButtonGroupContainer();
128 * Gets the popup header.
130 * @return Header properties of the pop-up menu.
132 IMPORT_C CAknPopupHeadingPane* Heading();
135 * Gets the popup header.
137 * @return Header properties of the pop-up menu.
139 IMPORT_C CAknPopupHeadingPane* Heading() const;
144 * @return The list box.
146 IMPORT_C CEikListBox* ListBox();
149 * Sets the maximum height for the popup frame.
151 * @param aItems The maximum height.
153 IMPORT_C void SetMaximumHeight(TInt aItems);
156 * Enables the findbox of the popup list.
158 * @param aEnable Enables (default) or disables the findbox.
159 * @return @c ETrue if enabling/disabling was successfull.
161 IMPORT_C TBool EnableFind(TBool aEnable=ETrue);
164 * Enables the findbox with adaptive search of the popup list.
167 * @param aEnable Enables (default) or disables the adaptive findbox.
168 * @return @c ETrue if enabling/disabling was successfull.
170 IMPORT_C TBool EnableAdaptiveFind(TBool aEnable=ETrue);
173 * Gets the search field control.
175 * @return Search field control.
177 IMPORT_C CAknSearchField* FindBox() const;
180 * From @c CCoeControl.
182 * Handles pointer events of popups.
184 * @param aPointerEvent Pointer event to be handled.
186 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
189 * From @c MEikCommandObserver.
191 * Processes events from the softkeys. Responds to @c EAknSoftkeyOk and
192 * @c EAknSoftkeyBack to accept or cancel the pop-up.
194 * @param aCommandId Event Id from the soft-key.
196 IMPORT_C void ProcessCommandL(TInt aCommandId);
199 * From @c MEikListBoxObserver.
201 * Processes key events from the listbox. Responds to
202 * @c EEventEnterKeyPressed to accept the pop-up.
204 * @param aListBox Listbox being observed.
205 * @param aEventType Event being observed.
207 IMPORT_C void HandleListBoxEventL(CEikListBox* aListBox,
208 TListBoxEvent aEventType);
210 * From @c MCoeControlObserver.
212 * Handles an event from an observed control.
214 * @param aControl Control being observed.
215 * @param aEventType Event observed.
217 IMPORT_C void HandleControlEventL(CCoeControl* aControl,
218 TCoeEvent aEventType);
222 * C++ default constructor.
224 IMPORT_C CAknPopupList();
229 IMPORT_C ~CAknPopupList();
232 * Handles 2nd phase construction.
234 * @param aListBox Pre-existing listbox-derived class.
235 * @param aCbaResource Softkey pane to display while pop-up is active.
236 * @param aType The layout used.
238 IMPORT_C void ConstructL(CEikListBox* aListBox,
240 AknPopupLayouts::TAknPopupLayouts aType );
243 * Called when the user accepts or cancels the listbox.
245 * @param aAccept @c ETrue if the user has accepted, @c EFalse if the user
246 * has cancelled the listbox.
248 IMPORT_C virtual void AttemptExitL(TBool aAccept);
251 * Setup the whole window layout; window position, grid and heading
252 * position, shadow for the window.
254 * @param aType A choice of layout.
256 IMPORT_C virtual void SetupWindowLayout(
257 AknPopupLayouts::TAknPopupLayouts aType);
260 * Returns the listbox being used.
262 * @return Listbox contained in the pop-up.
264 IMPORT_C CEikListBox* ListBox() const;
267 * Gets the layout definitions for the popup list.
269 * @return Collects all LAF specification lines that are needed for popup
272 IMPORT_C const TAknPopupWindowLayoutDef& Layout() const;
275 * Gets the layout definitions for the popup list.
277 * @return Collects all LAF specification lines that are needed for popup
280 IMPORT_C TAknPopupWindowLayoutDef& Layout();
285 * From @c MopSupplyObject.
287 * Retrieves an object of the same type as that encapsulated in @c aId.
289 * @param aId Encapsulated object type ID.
290 * @return Encapsulates the pointer to the object provided.
291 * Note that the encapsulated pointer may be NULL.
293 IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
298 * From @c CCoeControl.
300 * Handles a change to the control's resources.
302 * @param aType A message UID value.
304 IMPORT_C void HandleResourceChange(TInt aType);
307 IMPORT_C void FadeBehindPopup(TBool aFade);
312 // the following needs to be imported, because they need to be
313 // used in virtual table of any derived class.
314 IMPORT_C TSize MinimumSize();
315 IMPORT_C CCoeControl* ComponentControl(TInt aIndex) const;
316 IMPORT_C TInt CountComponentControls() const;
317 IMPORT_C void Draw(const TRect& aRect) const;
318 IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,
320 IMPORT_C void FocusChanged(TDrawNow aDrawNow);
322 IMPORT_C void CloseState();
323 // From MAknFadedComponent
324 IMPORT_C virtual TInt CountFadedComponents();
325 IMPORT_C virtual CCoeControl* FadedComponent(TInt aIndex);
331 IMPORT_C void* ExtensionInterface( TUid aInterface );
334 void RemoveFindFiltering();
336 protected: // these are protected to allow overriding virtual functions.
337 CEikListBox* iListBox;
340 * A button group container - a wrapper around the different button
343 CEikButtonGroupContainer* iPopoutCba;
346 * Header control for queries. Defines properties of the header of the
349 CAknPopupHeadingPane* iTitle;
351 /** The address to hold the return value from the popup */
358 TInt iCurrentResource;
360 /** Popup layout type. */
361 AknPopupLayouts::TAknPopupLayouts iWindowType;
364 * collects all LAF specification lines that are needed for popup window.
366 TAknPopupWindowLayoutDef iLayout;
370 TBool iAppBroughtForwards;
373 TAknPopupFader iPopupFader;
380 CActiveSchedulerWait iWait; // owned, safe to use as direct member data.
382 CAknPopupListExtension* iPopupListExtension; // owned