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.
16 * Support for popup setting item lists. THe MAknQueryValue abstract type is
17 * used to carry the state of the selection.
19 * This file also contains the definition for the contained editor of the setting page,
20 * CAknPopupSettingList
26 #ifndef __AKNPOPUPSETTINGPAGE_H__
27 #define __AKNPOPUPSETTINGPAGE_H__
30 #include <aknqueryvalue.h>
31 #include <aknqueryvaluetext.h>
32 #include <aknlistboxsettingpage.h>
34 #include <AknDesCArrayDecorator.h>
35 #include <AknListBoxLayoutDecorator.h>
37 class CAknPopupSettingList;
38 class CAknPopupSettingListExtension;
41 * This interface should be implemented by classes that need to know
42 * about events occurring in the popup field control
44 class MAknPopupSettingListObserver
50 enum TAknPopupSettingListEvent
52 EAknPopupSettingSelectionAndRequestAccept,
53 EAknPopupSettingSelectionAndStayOpen,
54 EAknPopupSettingSelectionAndClose
58 * Handle events from the popup field control, such as when it changes between
59 * selection list mode and label mode.
61 * Implementations of this observer routine should perform a base call to this specific
62 * method, in order to pick up any default re-layout actions.
64 * @param aPopupSettingList pointer to the popup field control that generated the event
65 * @param aEventType the type of event
66 * @param aHint for possible future use
69 virtual void HandlePopupSettingListEventL( CAknPopupSettingList* aPopupSettingList,
70 TAknPopupSettingListEvent aEventType,
76 * Represents menu list that appears in a popped up setting item
78 class CAknPopupSettingList :
79 public CAknSetStyleListBox,
80 public MEikListBoxObserver
88 * Standard constructor.
90 IMPORT_C CAknPopupSettingList();
96 IMPORT_C ~CAknPopupSettingList();
99 * 2nd phase construction
102 IMPORT_C void ConstructL();
105 * Sets flag that enables user defined entry. Note that flag can also be set from resources,
106 * but this method allows behaviour to be changed at runtime.
108 * @param aAllows if ETrue, set flag; if EFalse, clear flag.
110 IMPORT_C void SetAllowsUserDefinedEntry(TBool aAllows);
114 * Used by the client to set the query value used to represent the user defined
115 * value belonging to this popup field control.
117 * @param aValue pointer to value, ownership is not passed
120 IMPORT_C void SetQueryValueL(MAknQueryValue* aValue);
124 * Set the flag which determines whether the indicators are shown
125 * In practice the indicators have the appearance of radio buttons
127 * @param aShowIndicators
128 * If ETrue, indicators are displayed;
129 * if EFalse, indicators are not displayed
132 IMPORT_C void SetShowIndicators(TBool aShowIndicators);
135 * number of lines used
137 * @return number of lines being currently displayed by control, which is determined
138 * by the number of entries on the selection list, and whether the selection list is active.
139 * NOTE that the number is limited by KAknMaxLinesOnOnePage
142 IMPORT_C TInt NumLines() const;
145 * set an observer of this class to receive events from popup setting list
147 * @param aObserver pointer to the class that implements the observer interface,
150 IMPORT_C void SetPopupSettingListObserver(MAknPopupSettingListObserver* aObserver);
155 * Construct from resources.
156 * @param aReader constucted and positioned TResourceReader&
158 IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
163 * Create the popup list.
166 IMPORT_C void CreateMenuListL();
169 * Causes the list of pre-defined values to appear.
170 * Use this method to activate the pop-up field from a menu option command.
171 * Note that the desired control must have the focus before it can be activated.
174 IMPORT_C void ActivateMenuListL();
178 * This routine sets up the text arrays for the menu list
181 IMPORT_C void ConfigureMenuListL();
184 * All this does now is remove this from the stack
187 IMPORT_C void DestroyMenuList();
191 * From CCoeControl. Handles pointer event
192 * @param aPointerEvent Pointer event to be handled
194 IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent );
196 IMPORT_C void HandleResourceChange(TInt aType);
202 IMPORT_C void* ExtensionInterface( TUid aInterface );
206 * From MEikListBoxObserver
207 * Processes key events from the listbox. Responds to EEventEnterKeyPressed to accept
210 * @param aListBox Listbox being observed
211 * @param aEventType Event observed
214 * This implementation is vestige of former implementation when the listbox was wrapped up,
215 * not derived from. Currently observing itself..
218 IMPORT_C void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
220 private: // from CCoeControl
221 IMPORT_C void Reserved_1();
222 IMPORT_C void Reserved_2();
224 void CommonConstructL();
225 void SetUpSelectionListL();
227 * Set up the bitmap array for the "not pushed" and "pushed in" states
230 void InitialiseRadioButtonBitmapsL();
233 * Configures the decoration according to the currently set flags.
234 * Should be called whenever the flags are changed.
237 void ConfigureDecorator();
239 * Configures the layout decoration according to the "has buttons" flag
240 * Should be called whenever the flags are changed.
243 void ConstructLayoutDecoratorL();
246 // the following members are owned
248 TAknDesCArrayDecorator iDecorator;
249 CAknListBoxLayoutDecorator* iLayoutDecorator;
251 // the following fields are reflected in the POPUP_SETTING_LIST resource structure
255 TInt iCurrentSelection;
256 // elements to hold info regarding "new Item"- produced setting page
257 TInt iNewItemSettingPageResourceId;
258 TInt iNewItemEditorType;
259 TInt iNewItemEditorControlResourceId;
261 // the following members are not owned
262 MAknQueryValue* iValue;
263 MAknPopupSettingListObserver* iPopupSettingListObserver;
266 CAknPopupSettingListExtension* iExtension;
271 * Interface for the setting page containing a menu list with a Query value data model
272 * This is the more generic of the list-style setting pages.
275 class CAknPopupSettingPage :
276 public CAknListBoxSettingPage,
277 public MAknPopupSettingListObserver
282 * C++ constructor. This constructor uses just the setting page resource Id to
283 * construct the setting page, using listbox resource contained in the setting page
285 * @param aResourceId a resource identifier for a AVKON_SETTING_PAGE resource
286 * @param aQueryValue a reference to a query value object
288 IMPORT_C CAknPopupSettingPage(TInt aResourceID, MAknQueryValue& aQueryValue );
291 * Constructor that allows separate setting page and editor resources
293 * This constructor allows the use of setting page using only the editor resource. Other combinations are also possible
295 * In all cases the number (if supplied i.e. <> 0 ) is used.
297 * Editor Resource Setting Page Resource
298 * present present Both are used (but text & number overridden)
299 * = 0 present Editor resource is used via SP resource (Effectively like the other constructor)
300 * present = 0 Default Avkon SP resource if used + this editor resource
301 * = 0 = 0 uses default resource for both SP and editor. This is OK if:
302 * i) control type is present,
303 * ii) a default resource exists ( OK for text, integer, date, time, duration )
305 * Note: THe first argument is a TDesC* (rather than TDesC&) because the other constructor
306 * cannot initialize such a member without allocation or having an internal dummy buffer.
308 * Rules for text and numbers: The rules are the same for both: (non-zero length) text or number other
309 * than EAknSettingPageNoOrdinalDisplayed if given in this constructor will not override resource
310 * (unless that is zero length or EAknSettingPageNoOrdinalDisplayed). Note, however, that text or number given via the
311 * specific API for setting them, WILL override resource.
312 * It is assumed that number from resource is very rare. Special text is somewhat more likely.
314 * @param aSettingTitleText Text at top of setting pane
315 * @param aSettingNumber Number at top left (if present)
316 * @param aControlType Determines the type constructed and how its resource is read
317 * @param aEditorResourceId Editor resource to use in the setting page (if present)
318 * @param aSettingPageResourceId Setting Page to use (if present)
319 * @param aQueryValue reference to a query value object
321 IMPORT_C CAknPopupSettingPage( const TDesC* aSettingTitleText,
324 TInt aEditorResourceId,
325 TInt aSettingPageResourceId,
326 MAknQueryValue& aQueryValue);
329 * 2nd stage construction method. Type specific work is done here; most of the setting
330 * page constuction is performed in a call the base contstruction of CAknSettingPage
333 IMPORT_C virtual void ConstructL();
336 * Access to the contained listbox (inside popup setting list)
338 * @return CAknSetStyleListBox* pointer to the listbox used in the setting page; Does not transfer ownership
340 IMPORT_C CAknSetStyleListBox* ListBoxControl() const;
343 * Access to the editor control
345 * @return CAknPopupSettingList* a reference to the contained "editor" as a listbox; no ownership transferred
347 IMPORT_C CAknPopupSettingList* PopupSettingListBox() const;
350 * From MAknPopupSettingListObserver
351 * Handle events from the popup field control, such as when it changes between
352 * selection list mode and label mode.
354 * @param aPopupSettingList pointer to the popup field control that generated the event
355 * @param aEventType the type of event
356 * @param aHint for possible future use
359 IMPORT_C virtual void HandlePopupSettingListEventL(CAknPopupSettingList* aPopupSettingList,
360 TAknPopupSettingListEvent aEventType, TInt aHint);
363 * Can be used dynamically to set a new query value. This manages the setting up of the new
364 * PopupSettingList and its listbox, and also the resizing and redrawing of the setting page
365 * Note that all former query value objects and its associated arrays are owned by the client
366 * and if no longer used, should be deleted.
368 * @param MAknQueryValue* aQueryValue - the new value; no transfer of ownership
370 IMPORT_C void UpdateQueryValueL( MAknQueryValue* aQueryValue );
375 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
381 IMPORT_C virtual ~CAknPopupSettingPage();
384 * This is required to give access to the QueryValue data member from
385 * re-implementations of the popup setting page
387 * @return MAknQueryValue* a pointer to the query value object
390 IMPORT_C MAknQueryValue* QueryValue() const;
393 * This method should be implemented in listbox classes to move the selection in
394 * listbox editors prior to exiting from the setting page
397 IMPORT_C virtual void SelectCurrentItemL();
400 // CoeControl Framework and reserved methods
405 * Writes the internal state of the control and its components to aStream.
406 * Does nothing in release mode.
407 * Designed to be overidden and base called by subclasses.
409 * @param aWriteSteam A connected write stream
411 IMPORT_C virtual void WriteInternalStateL(RWriteStream& aWriteStream) const;
414 * Reserved method derived from CCoeControl
416 IMPORT_C virtual void Reserved_2();
422 IMPORT_C void* ExtensionInterface( TUid aInterface );
425 * New reserved methods for CAknSettingPage hierarchy
428 IMPORT_C virtual void CAknSettingPage_Reserved_1();
429 IMPORT_C virtual void CAknSettingPage_Reserved_2();
433 * New reserved method from CAknListBoxSettingPage
436 IMPORT_C virtual void CAknListBoxSettingPage_Reserved_1();
440 // The objects pointed to or referenced by this is not owned
441 MAknQueryValue& iQueryValue;