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
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     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
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description: 
williamr@2
    15
*  Check box list support for setting page in editable state
williamr@2
    16
*
williamr@2
    17
*
williamr@2
    18
*/
williamr@2
    19
williamr@2
    20
williamr@2
    21
#ifndef __AKNCHECKBOXSETTINGPAGE_H__
williamr@2
    22
#define __AKNCHECKBOXSETTINGPAGE_H__ 
williamr@2
    23
williamr@2
    24
williamr@2
    25
#include <aknlistboxsettingpage.h>
williamr@2
    26
williamr@2
    27
// forward declare
williamr@2
    28
class CAknCheckBoxSettingPageExtension;
williamr@2
    29
williamr@2
    30
/**
williamr@2
    31
* Class to encapsulate text and Boolean status; An array of these provides the interface to the CheckBoxSettingPage
williamr@2
    32
* The boolean status can be changed after construction, but the text cannot be changed.
williamr@2
    33
*
williamr@2
    34
*
williamr@2
    35
*/
williamr@2
    36
class CSelectableItem : public CBase
williamr@2
    37
{
williamr@2
    38
public :
williamr@2
    39
	/**
williamr@2
    40
	* C++ constructor
williamr@2
    41
	* @param	aItemText	text to go into the compound type
williamr@2
    42
	* @param	aSelected	Pass ETrue to select the item; EFalse to deselect it.
williamr@2
    43
	*/
williamr@2
    44
	IMPORT_C CSelectableItem( TDesC& aItemText, TBool aSelected  );
williamr@2
    45
	/**
williamr@2
    46
	* C++ Destructor
williamr@2
    47
	*/
williamr@2
    48
	virtual ~CSelectableItem();
williamr@2
    49
williamr@2
    50
	/** 
williamr@2
    51
	* 2nd stage construction
williamr@2
    52
	*
williamr@2
    53
	*/
williamr@2
    54
	IMPORT_C void ConstructL();
williamr@2
    55
williamr@2
    56
	/**
williamr@2
    57
	* Set the selection status to ETrue or EFalse
williamr@2
    58
	* 
williamr@2
    59
	* @param	aSelected	status that the selection status is to be set to.
williamr@2
    60
	*/
williamr@2
    61
	IMPORT_C void SetSelectionStatus( TBool aSelected );
williamr@2
    62
williamr@2
    63
	/**
williamr@2
    64
	* Access the selection status
williamr@2
    65
	* @return	EFalse if not selected; otherwise not EFalse
williamr@2
    66
	*/
williamr@2
    67
	IMPORT_C TBool SelectionStatus();
williamr@2
    68
williamr@2
    69
	/**
williamr@2
    70
	* Access to the item text as TPtr
williamr@2
    71
	* @return	TPtrC that points to items's text.
williamr@2
    72
	*/
williamr@2
    73
	IMPORT_C TPtrC ItemText();
williamr@2
    74
williamr@2
    75
private:
williamr@2
    76
	TDesC& iDesC;	// Holds the reference to the descriptor prior to construction
williamr@2
    77
	HBufC* iItem;	// This is on the heap and is used post constuction
williamr@2
    78
	TBool iSelected;
williamr@2
    79
};
williamr@2
    80
williamr@2
    81
williamr@2
    82
/**
williamr@2
    83
* Array type for holding selection items
williamr@2
    84
*
williamr@2
    85
*/
williamr@2
    86
class CSelectionItemList : public CArrayPtrFlat<CSelectableItem>, public MDesCArray
williamr@2
    87
	{
williamr@2
    88
public:
williamr@2
    89
	/**
williamr@2
    90
	* Constructor
williamr@2
    91
	*/
williamr@2
    92
	IMPORT_C CSelectionItemList( TInt Granularity );
williamr@2
    93
// from MDesCArray
williamr@2
    94
williamr@2
    95
	/**
williamr@2
    96
	* From MDesCArray:
williamr@2
    97
	*
williamr@2
    98
	* @return number of items in the array
williamr@2
    99
	*/
williamr@2
   100
	IMPORT_C TInt MdcaCount() const;
williamr@2
   101
williamr@2
   102
	/**
williamr@2
   103
	* Access to item text of the elements in the array
williamr@2
   104
	* @return item text of aIndex'th element
williamr@2
   105
	*/
williamr@2
   106
	IMPORT_C TPtrC MdcaPoint(TInt aIndex) const;
williamr@2
   107
	};
williamr@2
   108
williamr@2
   109
williamr@2
   110
williamr@2
   111
/**
williamr@2
   112
* Setting Page class supporting multiple selection. 
williamr@2
   113
*
williamr@2
   114
* Interface is via a CSelectionItemList array
williamr@2
   115
*
williamr@2
   116
*/
williamr@2
   117
class CAknCheckBoxSettingPage : public CAknListBoxSettingPage
williamr@2
   118
{
williamr@2
   119
public:
williamr@2
   120
	IMPORT_C CAknCheckBoxSettingPage(TInt aResourceID, CSelectionItemList* aItemArray );
williamr@2
   121
 /**
williamr@2
   122
 * Constructor that allows separate setting page and editor resources
williamr@2
   123
 *
williamr@2
   124
 * In all cases the number (if supplied i.e. <> 0 ) is used.  
williamr@2
   125
 *
williamr@2
   126
 *		Editor Resource		Setting Page Resource
williamr@2
   127
 *			present				present				Both are used (but text & number overridden)
williamr@2
   128
 *			 = 0				present				Editor resource is used via SP resource
williamr@2
   129
 *			present				= 0					Default Avkon SP resource if used (to no effect?)
williamr@2
   130
 *			 = 0				= 0					Not permitted
williamr@2
   131
 *
williamr@2
   132
 * Note: The first argument is a TDesC* (rather than TDesC&) because the other constructor
williamr@2
   133
 * cannot initialize such a member without allocation or having an internal dummy buffer.
williamr@2
   134
 *
williamr@2
   135
 * Rules for text and numbers: The rules are the same for both:  (non-zero length) text or number other 
williamr@2
   136
 * than EAknSettingPageNoOrdinalDisplayed if given in this constructor will not override resource 
williamr@2
   137
 * (unless that is zero length or EAknSettingPageNoOrdinalDisplayed).  Note, however, that text or number given via the 
williamr@2
   138
 * specific API for setting them, WILL override the resource.
williamr@2
   139
 * It is assumed that number from resource is very rare.  Special text is somewhat more likely.
williamr@2
   140
 * 
williamr@2
   141
 * @param aSettingTitleText	Text at top of setting pane
williamr@2
   142
 *	@param aSettingNumber		Number at top left (if present)
williamr@2
   143
 * @param aControlType			Determines the type constructed and how its resource is read
williamr@2
   144
 * @param aEditorResourceId	Editor resource to use in the setting page (if present)
williamr@2
   145
 * @param aSettingPageResourceId		Setting Page to use (if present)
williamr@2
   146
 * @param aItemArray			List of option texts and their selection states
williamr@2
   147
 */
williamr@2
   148
	IMPORT_C CAknCheckBoxSettingPage(	const TDesC* aSettingTitleText, 
williamr@2
   149
								TInt aSettingNumber, 
williamr@2
   150
								TInt aControlType,
williamr@2
   151
								TInt aEditorResourceId, 
williamr@2
   152
								TInt aSettingPageResourceId,
williamr@2
   153
								CSelectionItemList* aItemArray );
williamr@2
   154
williamr@2
   155
williamr@2
   156
	/**
williamr@2
   157
	* 2nd phase constructor
williamr@2
   158
	*
williamr@2
   159
	*/
williamr@2
   160
	IMPORT_C virtual void ConstructL();
williamr@2
   161
williamr@2
   162
	/** 
williamr@2
   163
	*
williamr@2
   164
	* Access to ListBoxControl
williamr@2
   165
	*
williamr@2
   166
	* @return pointer to listbox used by the setting page; No transfer of ownership
williamr@2
   167
	*/
williamr@2
   168
	IMPORT_C CAknSetStyleListBox* ListBoxControl() const;
williamr@2
   169
williamr@2
   170
	/**
williamr@2
   171
	* Method to update the item array after a change in content 
williamr@2
   172
	*
williamr@2
   173
	* @param CSelectionItemList* aItemArray	The new array of selectable items
williamr@2
   174
	*/
williamr@2
   175
	IMPORT_C void SetSelectionItemArrayL( CSelectionItemList* aItemArray );
williamr@2
   176
williamr@2
   177
// From MEikListBoxObserver
williamr@2
   178
	/**
williamr@2
   179
	* Observer callback from the listbox 
williamr@2
   180
	*
williamr@2
   181
	* @param	aListBox	ptr to listbox that is calling the method
williamr@2
   182
	* @param	aEventType	type of event; defined by MEikListBoxObserver
williamr@2
   183
	*/
williamr@2
   184
	IMPORT_C virtual void HandleListBoxEventL(CEikListBox* aListBox,
williamr@2
   185
				 MEikListBoxObserver::TListBoxEvent aEventType);
williamr@2
   186
williamr@2
   187
    /**
williamr@2
   188
    *  From CCoeControl
williamr@2
   189
    *  Handles pointer events
williamr@2
   190
    */	  
williamr@2
   191
    IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
williamr@2
   192
    
williamr@2
   193
    IMPORT_C void HandleResourceChange(TInt aType);
williamr@2
   194
williamr@2
   195
protected:
williamr@2
   196
	/**
williamr@2
   197
	* Destructor
williamr@2
   198
	*/ 
williamr@2
   199
	IMPORT_C virtual ~CAknCheckBoxSettingPage();
williamr@2
   200
williamr@2
   201
	/**
williamr@2
   202
	* Called when the setting is updated
williamr@2
   203
	*
williamr@2
   204
	*/
williamr@2
   205
	IMPORT_C virtual void UpdateSettingL();
williamr@2
   206
williamr@2
   207
	/**
williamr@2
   208
	* Called when the setting page is about to be displayed
williamr@2
   209
	*
williamr@2
   210
	*/
williamr@2
   211
	IMPORT_C void DynamicInitL();
williamr@2
   212
williamr@2
   213
	// From MEikCommandObserver
williamr@2
   214
	IMPORT_C virtual void ProcessCommandL(TInt aCommandId);
williamr@2
   215
	/*
williamr@2
   216
	* This method is called upon Select command id.  It should change the setting but not exit in
williamr@2
   217
	* this case.
williamr@2
   218
	*/
williamr@2
   219
	IMPORT_C virtual void SelectCurrentItemL();
williamr@2
   220
williamr@2
   221
//
williamr@2
   222
// CoeControl Framework and reserved methods
williamr@2
   223
//
williamr@2
   224
protected:
williamr@2
   225
williamr@2
   226
/**
williamr@2
   227
 * Writes the internal state of the control and its components to aStream.
williamr@2
   228
 * Does nothing in release mode.
williamr@2
   229
 * Designed to be overidden and base called by subclasses.
williamr@2
   230
 *
williamr@2
   231
 * @param	aWriteSteam		A connected write stream
williamr@2
   232
 */	
williamr@2
   233
	IMPORT_C virtual void WriteInternalStateL(RWriteStream& aWriteStream) const;
williamr@2
   234
private:
williamr@2
   235
    /**
williamr@2
   236
    * From CAknControl
williamr@2
   237
    */
williamr@2
   238
    IMPORT_C void* ExtensionInterface( TUid aInterface );
williamr@2
   239
williamr@2
   240
private:
williamr@2
   241
/**
williamr@2
   242
 *	Reserved method derived from CCoeControl
williamr@2
   243
 */
williamr@2
   244
	IMPORT_C virtual void Reserved_2();
williamr@2
   245
williamr@2
   246
/**
williamr@2
   247
 * New reserved methods for CAknSettingPage hierarchy
williamr@2
   248
 */ 
williamr@2
   249
private: 
williamr@2
   250
	IMPORT_C virtual void CAknSettingPage_Reserved_1();
williamr@2
   251
	IMPORT_C virtual void CAknSettingPage_Reserved_2();
williamr@2
   252
williamr@2
   253
private:
williamr@2
   254
/**
williamr@2
   255
 * New reserved method from CAknListBoxSettingPage 
williamr@2
   256
 *
williamr@2
   257
 */
williamr@2
   258
	IMPORT_C virtual void CAknListBoxSettingPage_Reserved_1();
williamr@2
   259
williamr@2
   260
private:
williamr@2
   261
	void UpdateAllSelections();
williamr@2
   262
	void SetAllSelectionsL();
williamr@2
   263
	void ToggleSelectionL();
williamr@2
   264
williamr@2
   265
	/**
williamr@2
   266
	* Internal method to re-generate the internal, "decorated" text array used in the
williamr@2
   267
	* real listbox. 
williamr@2
   268
	*/
williamr@2
   269
	void GenerateInternalArrayAndGiveToListBoxL();
williamr@2
   270
	
williamr@2
   271
	void CreateCheckBoxBitmapsL();
williamr@2
   272
williamr@2
   273
	CDesCArrayFlat* iInternalItemArray;	
williamr@2
   274
williamr@2
   275
	// the following are not owned
williamr@2
   276
	CSelectionItemList* iItemArray; 
williamr@2
   277
williamr@2
   278
    CAknCheckBoxSettingPageExtension* iExtension; // owned
williamr@2
   279
};
williamr@2
   280
williamr@2
   281
#endif