epoc32/include/mw/akncheckboxsettingpage.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 /*
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *  Check box list support for setting page in editable state
    16 *
    17 *
    18 */
    19 
    20 
    21 #ifndef __AKNCHECKBOXSETTINGPAGE_H__
    22 #define __AKNCHECKBOXSETTINGPAGE_H__ 
    23 
    24 
    25 #include <aknlistboxsettingpage.h>
    26 
    27 // forward declare
    28 class CAknCheckBoxSettingPageExtension;
    29 
    30 /**
    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.
    33 *
    34 *
    35 */
    36 class CSelectableItem : public CBase
    37 {
    38 public :
    39 	/**
    40 	* C++ constructor
    41 	* @param	aItemText	text to go into the compound type
    42 	* @param	aSelected	Pass ETrue to select the item; EFalse to deselect it.
    43 	*/
    44 	IMPORT_C CSelectableItem( TDesC& aItemText, TBool aSelected  );
    45 	/**
    46 	* C++ Destructor
    47 	*/
    48 	virtual ~CSelectableItem();
    49 
    50 	/** 
    51 	* 2nd stage construction
    52 	*
    53 	*/
    54 	IMPORT_C void ConstructL();
    55 
    56 	/**
    57 	* Set the selection status to ETrue or EFalse
    58 	* 
    59 	* @param	aSelected	status that the selection status is to be set to.
    60 	*/
    61 	IMPORT_C void SetSelectionStatus( TBool aSelected );
    62 
    63 	/**
    64 	* Access the selection status
    65 	* @return	EFalse if not selected; otherwise not EFalse
    66 	*/
    67 	IMPORT_C TBool SelectionStatus();
    68 
    69 	/**
    70 	* Access to the item text as TPtr
    71 	* @return	TPtrC that points to items's text.
    72 	*/
    73 	IMPORT_C TPtrC ItemText();
    74 
    75 private:
    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
    78 	TBool iSelected;
    79 };
    80 
    81 
    82 /**
    83 * Array type for holding selection items
    84 *
    85 */
    86 class CSelectionItemList : public CArrayPtrFlat<CSelectableItem>, public MDesCArray
    87 	{
    88 public:
    89 	/**
    90 	* Constructor
    91 	*/
    92 	IMPORT_C CSelectionItemList( TInt Granularity );
    93 // from MDesCArray
    94 
    95 	/**
    96 	* From MDesCArray:
    97 	*
    98 	* @return number of items in the array
    99 	*/
   100 	IMPORT_C TInt MdcaCount() const;
   101 
   102 	/**
   103 	* Access to item text of the elements in the array
   104 	* @return item text of aIndex'th element
   105 	*/
   106 	IMPORT_C TPtrC MdcaPoint(TInt aIndex) const;
   107 	};
   108 
   109 
   110 
   111 /**
   112 * Setting Page class supporting multiple selection. 
   113 *
   114 * Interface is via a CSelectionItemList array
   115 *
   116 */
   117 class CAknCheckBoxSettingPage : public CAknListBoxSettingPage
   118 {
   119 public:
   120 	IMPORT_C CAknCheckBoxSettingPage(TInt aResourceID, CSelectionItemList* aItemArray );
   121  /**
   122  * Constructor that allows separate setting page and editor resources
   123  *
   124  * In all cases the number (if supplied i.e. <> 0 ) is used.  
   125  *
   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
   131  *
   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.
   134  *
   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.
   140  * 
   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
   147  */
   148 	IMPORT_C CAknCheckBoxSettingPage(	const TDesC* aSettingTitleText, 
   149 								TInt aSettingNumber, 
   150 								TInt aControlType,
   151 								TInt aEditorResourceId, 
   152 								TInt aSettingPageResourceId,
   153 								CSelectionItemList* aItemArray );
   154 
   155 
   156 	/**
   157 	* 2nd phase constructor
   158 	*
   159 	*/
   160 	IMPORT_C virtual void ConstructL();
   161 
   162 	/** 
   163 	*
   164 	* Access to ListBoxControl
   165 	*
   166 	* @return pointer to listbox used by the setting page; No transfer of ownership
   167 	*/
   168 	IMPORT_C CAknSetStyleListBox* ListBoxControl() const;
   169 
   170 	/**
   171 	* Method to update the item array after a change in content 
   172 	*
   173 	* @param CSelectionItemList* aItemArray	The new array of selectable items
   174 	*/
   175 	IMPORT_C void SetSelectionItemArrayL( CSelectionItemList* aItemArray );
   176 
   177 // From MEikListBoxObserver
   178 	/**
   179 	* Observer callback from the listbox 
   180 	*
   181 	* @param	aListBox	ptr to listbox that is calling the method
   182 	* @param	aEventType	type of event; defined by MEikListBoxObserver
   183 	*/
   184 	IMPORT_C virtual void HandleListBoxEventL(CEikListBox* aListBox,
   185 				 MEikListBoxObserver::TListBoxEvent aEventType);
   186 
   187     /**
   188     *  From CCoeControl
   189     *  Handles pointer events
   190     */	  
   191     IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
   192     
   193     IMPORT_C void HandleResourceChange(TInt aType);
   194 
   195 protected:
   196 	/**
   197 	* Destructor
   198 	*/ 
   199 	IMPORT_C virtual ~CAknCheckBoxSettingPage();
   200 
   201 	/**
   202 	* Called when the setting is updated
   203 	*
   204 	*/
   205 	IMPORT_C virtual void UpdateSettingL();
   206 
   207 	/**
   208 	* Called when the setting page is about to be displayed
   209 	*
   210 	*/
   211 	IMPORT_C void DynamicInitL();
   212 
   213 	// From MEikCommandObserver
   214 	IMPORT_C virtual void ProcessCommandL(TInt aCommandId);
   215 	/*
   216 	* This method is called upon Select command id.  It should change the setting but not exit in
   217 	* this case.
   218 	*/
   219 	IMPORT_C virtual void SelectCurrentItemL();
   220 
   221 //
   222 // CoeControl Framework and reserved methods
   223 //
   224 protected:
   225 
   226 /**
   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.
   230  *
   231  * @param	aWriteSteam		A connected write stream
   232  */	
   233 	IMPORT_C virtual void WriteInternalStateL(RWriteStream& aWriteStream) const;
   234 private:
   235     /**
   236     * From CAknControl
   237     */
   238     IMPORT_C void* ExtensionInterface( TUid aInterface );
   239 
   240 private:
   241 /**
   242  *	Reserved method derived from CCoeControl
   243  */
   244 	IMPORT_C virtual void Reserved_2();
   245 
   246 /**
   247  * New reserved methods for CAknSettingPage hierarchy
   248  */ 
   249 private: 
   250 	IMPORT_C virtual void CAknSettingPage_Reserved_1();
   251 	IMPORT_C virtual void CAknSettingPage_Reserved_2();
   252 
   253 private:
   254 /**
   255  * New reserved method from CAknListBoxSettingPage 
   256  *
   257  */
   258 	IMPORT_C virtual void CAknListBoxSettingPage_Reserved_1();
   259 
   260 private:
   261 	void UpdateAllSelections();
   262 	void SetAllSelectionsL();
   263 	void ToggleSelectionL();
   264 
   265 	/**
   266 	* Internal method to re-generate the internal, "decorated" text array used in the
   267 	* real listbox. 
   268 	*/
   269 	void GenerateInternalArrayAndGiveToListBoxL();
   270 	
   271 	void CreateCheckBoxBitmapsL();
   272 
   273 	CDesCArrayFlat* iInternalItemArray;	
   274 
   275 	// the following are not owned
   276 	CSelectionItemList* iItemArray; 
   277 
   278     CAknCheckBoxSettingPageExtension* iExtension; // owned
   279 };
   280 
   281 #endif