williamr@2: /* williamr@2: * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * Check box list support for setting page in editable state williamr@2: * williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef __AKNCHECKBOXSETTINGPAGE_H__ williamr@2: #define __AKNCHECKBOXSETTINGPAGE_H__ williamr@2: williamr@2: williamr@4: #include williamr@2: williamr@2: // forward declare williamr@2: class CAknCheckBoxSettingPageExtension; williamr@2: williamr@2: /** williamr@2: * Class to encapsulate text and Boolean status; An array of these provides the interface to the CheckBoxSettingPage williamr@2: * The boolean status can be changed after construction, but the text cannot be changed. williamr@2: * williamr@2: * williamr@2: */ williamr@2: class CSelectableItem : public CBase williamr@2: { williamr@2: public : williamr@2: /** williamr@2: * C++ constructor williamr@2: * @param aItemText text to go into the compound type williamr@2: * @param aSelected Pass ETrue to select the item; EFalse to deselect it. williamr@2: */ williamr@2: IMPORT_C CSelectableItem( TDesC& aItemText, TBool aSelected ); williamr@2: /** williamr@2: * C++ Destructor williamr@2: */ williamr@2: virtual ~CSelectableItem(); williamr@2: williamr@2: /** williamr@2: * 2nd stage construction williamr@2: * williamr@2: */ williamr@2: IMPORT_C void ConstructL(); williamr@2: williamr@2: /** williamr@2: * Set the selection status to ETrue or EFalse williamr@2: * williamr@2: * @param aSelected status that the selection status is to be set to. williamr@2: */ williamr@2: IMPORT_C void SetSelectionStatus( TBool aSelected ); williamr@2: williamr@2: /** williamr@2: * Access the selection status williamr@2: * @return EFalse if not selected; otherwise not EFalse williamr@2: */ williamr@2: IMPORT_C TBool SelectionStatus(); williamr@2: williamr@2: /** williamr@2: * Access to the item text as TPtr williamr@2: * @return TPtrC that points to items's text. williamr@2: */ williamr@2: IMPORT_C TPtrC ItemText(); williamr@2: williamr@2: private: williamr@2: TDesC& iDesC; // Holds the reference to the descriptor prior to construction williamr@2: HBufC* iItem; // This is on the heap and is used post constuction williamr@2: TBool iSelected; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: * Array type for holding selection items williamr@2: * williamr@2: */ williamr@2: class CSelectionItemList : public CArrayPtrFlat, public MDesCArray williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Constructor williamr@2: */ williamr@2: IMPORT_C CSelectionItemList( TInt Granularity ); williamr@2: // from MDesCArray williamr@2: williamr@2: /** williamr@2: * From MDesCArray: williamr@2: * williamr@2: * @return number of items in the array williamr@2: */ williamr@2: IMPORT_C TInt MdcaCount() const; williamr@2: williamr@2: /** williamr@2: * Access to item text of the elements in the array williamr@2: * @return item text of aIndex'th element williamr@2: */ williamr@2: IMPORT_C TPtrC MdcaPoint(TInt aIndex) const; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: * Setting Page class supporting multiple selection. williamr@2: * williamr@2: * Interface is via a CSelectionItemList array williamr@2: * williamr@2: */ williamr@2: class CAknCheckBoxSettingPage : public CAknListBoxSettingPage williamr@2: { williamr@2: public: williamr@2: IMPORT_C CAknCheckBoxSettingPage(TInt aResourceID, CSelectionItemList* aItemArray ); williamr@2: /** williamr@2: * Constructor that allows separate setting page and editor resources williamr@2: * williamr@2: * In all cases the number (if supplied i.e. <> 0 ) is used. williamr@2: * williamr@2: * Editor Resource Setting Page Resource williamr@2: * present present Both are used (but text & number overridden) williamr@2: * = 0 present Editor resource is used via SP resource williamr@2: * present = 0 Default Avkon SP resource if used (to no effect?) williamr@2: * = 0 = 0 Not permitted williamr@2: * williamr@2: * Note: The first argument is a TDesC* (rather than TDesC&) because the other constructor williamr@2: * cannot initialize such a member without allocation or having an internal dummy buffer. williamr@2: * williamr@2: * Rules for text and numbers: The rules are the same for both: (non-zero length) text or number other williamr@2: * than EAknSettingPageNoOrdinalDisplayed if given in this constructor will not override resource williamr@2: * (unless that is zero length or EAknSettingPageNoOrdinalDisplayed). Note, however, that text or number given via the williamr@2: * specific API for setting them, WILL override the resource. williamr@2: * It is assumed that number from resource is very rare. Special text is somewhat more likely. williamr@2: * williamr@2: * @param aSettingTitleText Text at top of setting pane williamr@2: * @param aSettingNumber Number at top left (if present) williamr@2: * @param aControlType Determines the type constructed and how its resource is read williamr@2: * @param aEditorResourceId Editor resource to use in the setting page (if present) williamr@2: * @param aSettingPageResourceId Setting Page to use (if present) williamr@2: * @param aItemArray List of option texts and their selection states williamr@2: */ williamr@2: IMPORT_C CAknCheckBoxSettingPage( const TDesC* aSettingTitleText, williamr@2: TInt aSettingNumber, williamr@2: TInt aControlType, williamr@2: TInt aEditorResourceId, williamr@2: TInt aSettingPageResourceId, williamr@2: CSelectionItemList* aItemArray ); williamr@2: williamr@2: williamr@2: /** williamr@2: * 2nd phase constructor williamr@2: * williamr@2: */ williamr@2: IMPORT_C virtual void ConstructL(); williamr@2: williamr@2: /** williamr@2: * williamr@2: * Access to ListBoxControl williamr@2: * williamr@2: * @return pointer to listbox used by the setting page; No transfer of ownership williamr@2: */ williamr@2: IMPORT_C CAknSetStyleListBox* ListBoxControl() const; williamr@2: williamr@2: /** williamr@2: * Method to update the item array after a change in content williamr@2: * williamr@2: * @param CSelectionItemList* aItemArray The new array of selectable items williamr@2: */ williamr@2: IMPORT_C void SetSelectionItemArrayL( CSelectionItemList* aItemArray ); williamr@2: williamr@2: // From MEikListBoxObserver williamr@2: /** williamr@2: * Observer callback from the listbox williamr@2: * williamr@2: * @param aListBox ptr to listbox that is calling the method williamr@2: * @param aEventType type of event; defined by MEikListBoxObserver williamr@2: */ williamr@2: IMPORT_C virtual void HandleListBoxEventL(CEikListBox* aListBox, williamr@2: MEikListBoxObserver::TListBoxEvent aEventType); williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * Handles pointer events williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: IMPORT_C void HandleResourceChange(TInt aType); williamr@2: williamr@2: protected: williamr@2: /** williamr@2: * Destructor williamr@2: */ williamr@2: IMPORT_C virtual ~CAknCheckBoxSettingPage(); williamr@2: williamr@2: /** williamr@2: * Called when the setting is updated williamr@2: * williamr@2: */ williamr@2: IMPORT_C virtual void UpdateSettingL(); williamr@2: williamr@2: /** williamr@2: * Called when the setting page is about to be displayed williamr@2: * williamr@2: */ williamr@2: IMPORT_C void DynamicInitL(); williamr@2: williamr@2: // From MEikCommandObserver williamr@2: IMPORT_C virtual void ProcessCommandL(TInt aCommandId); williamr@2: /* williamr@2: * This method is called upon Select command id. It should change the setting but not exit in williamr@2: * this case. williamr@2: */ williamr@2: IMPORT_C virtual void SelectCurrentItemL(); williamr@2: williamr@2: // williamr@2: // CoeControl Framework and reserved methods williamr@2: // williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * Writes the internal state of the control and its components to aStream. williamr@2: * Does nothing in release mode. williamr@2: * Designed to be overidden and base called by subclasses. williamr@2: * williamr@2: * @param aWriteSteam A connected write stream williamr@2: */ williamr@2: IMPORT_C virtual void WriteInternalStateL(RWriteStream& aWriteStream) const; williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: williamr@2: private: williamr@2: /** williamr@2: * Reserved method derived from CCoeControl williamr@2: */ williamr@2: IMPORT_C virtual void Reserved_2(); williamr@2: williamr@2: /** williamr@2: * New reserved methods for CAknSettingPage hierarchy williamr@2: */ williamr@2: private: williamr@2: IMPORT_C virtual void CAknSettingPage_Reserved_1(); williamr@2: IMPORT_C virtual void CAknSettingPage_Reserved_2(); williamr@2: williamr@2: private: williamr@2: /** williamr@2: * New reserved method from CAknListBoxSettingPage williamr@2: * williamr@2: */ williamr@2: IMPORT_C virtual void CAknListBoxSettingPage_Reserved_1(); williamr@2: williamr@2: private: williamr@2: void UpdateAllSelections(); williamr@2: void SetAllSelectionsL(); williamr@2: void ToggleSelectionL(); williamr@2: williamr@2: /** williamr@2: * Internal method to re-generate the internal, "decorated" text array used in the williamr@2: * real listbox. williamr@2: */ williamr@2: void GenerateInternalArrayAndGiveToListBoxL(); williamr@2: williamr@2: void CreateCheckBoxBitmapsL(); williamr@2: williamr@2: CDesCArrayFlat* iInternalItemArray; williamr@2: williamr@2: // the following are not owned williamr@2: CSelectionItemList* iItemArray; williamr@2: williamr@2: CAknCheckBoxSettingPageExtension* iExtension; // owned williamr@2: }; williamr@2: williamr@2: #endif