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 * Check box list support for setting page in editable state
21 #ifndef __AKNCHECKBOXSETTINGPAGE_H__
22 #define __AKNCHECKBOXSETTINGPAGE_H__
25 #include <aknlistboxsettingpage.h>
28 class CAknCheckBoxSettingPageExtension;
31 * Class to encapsulate text and Boolean status; An array of these provides the interface to the CheckBoxSettingPage
32 * The boolean status can be changed after construction, but the text cannot be changed.
36 class CSelectableItem : public CBase
41 * @param aItemText text to go into the compound type
42 * @param aSelected Pass ETrue to select the item; EFalse to deselect it.
44 IMPORT_C CSelectableItem( TDesC& aItemText, TBool aSelected );
48 virtual ~CSelectableItem();
51 * 2nd stage construction
54 IMPORT_C void ConstructL();
57 * Set the selection status to ETrue or EFalse
59 * @param aSelected status that the selection status is to be set to.
61 IMPORT_C void SetSelectionStatus( TBool aSelected );
64 * Access the selection status
65 * @return EFalse if not selected; otherwise not EFalse
67 IMPORT_C TBool SelectionStatus();
70 * Access to the item text as TPtr
71 * @return TPtrC that points to items's text.
73 IMPORT_C TPtrC ItemText();
76 TDesC& iDesC; // Holds the reference to the descriptor prior to construction
77 HBufC* iItem; // This is on the heap and is used post constuction
83 * Array type for holding selection items
86 class CSelectionItemList : public CArrayPtrFlat<CSelectableItem>, public MDesCArray
92 IMPORT_C CSelectionItemList( TInt Granularity );
98 * @return number of items in the array
100 IMPORT_C TInt MdcaCount() const;
103 * Access to item text of the elements in the array
104 * @return item text of aIndex'th element
106 IMPORT_C TPtrC MdcaPoint(TInt aIndex) const;
112 * Setting Page class supporting multiple selection.
114 * Interface is via a CSelectionItemList array
117 class CAknCheckBoxSettingPage : public CAknListBoxSettingPage
120 IMPORT_C CAknCheckBoxSettingPage(TInt aResourceID, CSelectionItemList* aItemArray );
122 * Constructor that allows separate setting page and editor resources
124 * In all cases the number (if supplied i.e. <> 0 ) is used.
126 * Editor Resource Setting Page Resource
127 * present present Both are used (but text & number overridden)
128 * = 0 present Editor resource is used via SP resource
129 * present = 0 Default Avkon SP resource if used (to no effect?)
130 * = 0 = 0 Not permitted
132 * Note: The first argument is a TDesC* (rather than TDesC&) because the other constructor
133 * cannot initialize such a member without allocation or having an internal dummy buffer.
135 * Rules for text and numbers: The rules are the same for both: (non-zero length) text or number other
136 * than EAknSettingPageNoOrdinalDisplayed if given in this constructor will not override resource
137 * (unless that is zero length or EAknSettingPageNoOrdinalDisplayed). Note, however, that text or number given via the
138 * specific API for setting them, WILL override the resource.
139 * It is assumed that number from resource is very rare. Special text is somewhat more likely.
141 * @param aSettingTitleText Text at top of setting pane
142 * @param aSettingNumber Number at top left (if present)
143 * @param aControlType Determines the type constructed and how its resource is read
144 * @param aEditorResourceId Editor resource to use in the setting page (if present)
145 * @param aSettingPageResourceId Setting Page to use (if present)
146 * @param aItemArray List of option texts and their selection states
148 IMPORT_C CAknCheckBoxSettingPage( const TDesC* aSettingTitleText,
151 TInt aEditorResourceId,
152 TInt aSettingPageResourceId,
153 CSelectionItemList* aItemArray );
157 * 2nd phase constructor
160 IMPORT_C virtual void ConstructL();
164 * Access to ListBoxControl
166 * @return pointer to listbox used by the setting page; No transfer of ownership
168 IMPORT_C CAknSetStyleListBox* ListBoxControl() const;
171 * Method to update the item array after a change in content
173 * @param CSelectionItemList* aItemArray The new array of selectable items
175 IMPORT_C void SetSelectionItemArrayL( CSelectionItemList* aItemArray );
177 // From MEikListBoxObserver
179 * Observer callback from the listbox
181 * @param aListBox ptr to listbox that is calling the method
182 * @param aEventType type of event; defined by MEikListBoxObserver
184 IMPORT_C virtual void HandleListBoxEventL(CEikListBox* aListBox,
185 MEikListBoxObserver::TListBoxEvent aEventType);
189 * Handles pointer events
191 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
193 IMPORT_C void HandleResourceChange(TInt aType);
199 IMPORT_C virtual ~CAknCheckBoxSettingPage();
202 * Called when the setting is updated
205 IMPORT_C virtual void UpdateSettingL();
208 * Called when the setting page is about to be displayed
211 IMPORT_C void DynamicInitL();
213 // From MEikCommandObserver
214 IMPORT_C virtual void ProcessCommandL(TInt aCommandId);
216 * This method is called upon Select command id. It should change the setting but not exit in
219 IMPORT_C virtual void SelectCurrentItemL();
222 // CoeControl Framework and reserved methods
227 * Writes the internal state of the control and its components to aStream.
228 * Does nothing in release mode.
229 * Designed to be overidden and base called by subclasses.
231 * @param aWriteSteam A connected write stream
233 IMPORT_C virtual void WriteInternalStateL(RWriteStream& aWriteStream) const;
238 IMPORT_C void* ExtensionInterface( TUid aInterface );
242 * Reserved method derived from CCoeControl
244 IMPORT_C virtual void Reserved_2();
247 * New reserved methods for CAknSettingPage hierarchy
250 IMPORT_C virtual void CAknSettingPage_Reserved_1();
251 IMPORT_C virtual void CAknSettingPage_Reserved_2();
255 * New reserved method from CAknListBoxSettingPage
258 IMPORT_C virtual void CAknListBoxSettingPage_Reserved_1();
261 void UpdateAllSelections();
262 void SetAllSelectionsL();
263 void ToggleSelectionL();
266 * Internal method to re-generate the internal, "decorated" text array used in the
269 void GenerateInternalArrayAndGiveToListBoxL();
271 void CreateCheckBoxBitmapsL();
273 CDesCArrayFlat* iInternalItemArray;
275 // the following are not owned
276 CSelectionItemList* iItemArray;
278 CAknCheckBoxSettingPageExtension* iExtension; // owned