epoc32/include/mw/akntextsettingpage.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 *     Interface for Setting page carrying CEikEdwin editors
    16 *		- CAknTextSettingPage: 6 line text editor
    17 *		- CAknIntegerSettingPage: 1 line integer editor
    18 *
    19 *
    20 */
    21 
    22 
    23 #ifndef __AKNTEXTSETTINGPAGE_H__
    24 #define __AKNTEXTSETTINGPAGE_H__ 
    25 
    26 // For coecontrol and its observer
    27 #include <coecntrl.h>
    28 #include <coecobs.h>
    29 
    30 #include <eikdef.h>
    31 #include <eikedwin.h>
    32 #include "aknsettingpage.h"
    33 #include "aknnumedwin.h"
    34 
    35 /**
    36 * This class is an intermediate pure virtual class for all setting page classes that host 
    37 * Edwins.
    38 *
    39 * It implements type-specific access to the hosted editor and common drawing code
    40 */
    41 class CAknEdwinSettingPage : public CAknSettingPage
    42 {
    43 
    44 public:
    45 
    46 	/**
    47 	*	Common access to the edwin for descendant classes
    48 	*
    49 	* @return Pointer to contained edwin control
    50 	*/
    51 	IMPORT_C CEikEdwin* TextControl();
    52 
    53     /**
    54     * From CCoeControl.     
    55     * Handles pointer events
    56     */
    57     IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
    58 
    59 protected:
    60 	/**
    61 	 * Simple constructor depending only on a single resource Id.
    62 	 *
    63 	 * @param aSettingPageResourceId	Setting Page resource id to use 
    64 	 */
    65 	IMPORT_C CAknEdwinSettingPage( TInt ResourceId );
    66 	/**
    67 	 * Constructor that allows separate setting page and editor resources
    68 	 * 
    69 	 * This constructor allows the use of setting page using only the editor resource.  Other combinations are also possible
    70 	 *
    71 	 * In all cases the number (if supplied i.e. <> 0 ) is used.  
    72 	 *
    73 	 *		Editor Resource		Setting Page Resource
    74 	 *			present					present				Both are used (but text & number overridden)
    75 	 *			 = 0					present				Editor resource is used via SP resource (Effectively like the other constructor)
    76 	 *			present					= 0					Default Avkon SP resource if used + this editor resource
    77 	 *			 = 0					= 0					uses default resource for both SP and editor. This is OK if:
    78 	 *	 i) control type is present, 
    79 	 *  ii) a default resource exists ( OK for text, integer, date, time, duration )
    80 	 *
    81 	 * Note: THe first argument is a TDesC* (rather than TDesC&) because the other constructor
    82 	 * cannot initialize such a member without allocation or having an internal dummy buffer.  
    83 	 * Note that this buffer must be owned by the client until ExecuteLD has been called.
    84 	 *
    85 	 * Rules for text and numbers: The rules are the same for both:  (non-zero length) text or number other 
    86 	 * than EAknSettingPageNoOrdinalDisplayed if given in this constructor will not override resource 
    87 	 * (unless that is zero length or EAknSettingPageNoOrdinalDisplayed).  Note, however, that text or number given via the 
    88 	 * specific API for setting them, WILL override resource.
    89 	 * It is assumed that number from resource is very rare.  Special text is somewhat more likely.
    90 	 * 
    91 	 * @param aSettingTitleText	Text at top of setting pane; EXTERNALLY OWNED
    92 	 * @param aSettingNumber		Number at top left (if present)
    93 	 * @param aControlType			Determines the type constructed and how its resource is read
    94 	 * @param aEditorResourceId	Editor resource to use in the setting page (if present)
    95 	 * @param aSettingPageResourceId		Setting Page to use (if present)
    96 	 */
    97 
    98 	IMPORT_C CAknEdwinSettingPage(
    99 								const TDesC* aSettingTitleText, 
   100 								TInt aSettingNumber, 
   101 								TInt aControlType,
   102 								TInt aEditorResourceId, 
   103 								TInt aSettingPageResourceId );
   104 
   105 //
   106 // From CCoeControl
   107 //
   108 protected:
   109 	/**
   110 	* No implementation of SizeChanged is delivered with this class
   111 	*
   112 	*/
   113 	virtual void SizeChanged() = 0;
   114 
   115 	/**
   116 	* Common draw function for laid-out descendent setting pages. 
   117 	* This should not need to be re-implemented as long as the rectangle members are
   118 	* all that is needed
   119 	*
   120 	* @param	aRect	rectangle within which to perform the draw
   121 	*/
   122 	IMPORT_C void Draw(const TRect& aRect) const;
   123 
   124 private:
   125     /**
   126     * From CAknControl
   127     */
   128     IMPORT_C void* ExtensionInterface( TUid aInterface );
   129 
   130 private:
   131 /**
   132  * New reserved method with this class
   133  *
   134  */
   135 	IMPORT_C virtual void CAknEdwinSettingPage_Reserved_1();
   136 
   137 protected:
   138 	/**
   139 	* Rectangle within which to layout the edwin. Not drawn
   140 	*/
   141 	TAknLayoutRect iEdwinLayoutRect;
   142 
   143 	/**
   144 	* Horizontal shadow rectangle
   145 	*/
   146 	TAknLayoutRect iHorizontalShadow;
   147 	
   148 	/**
   149 	* Vertical shadow rectangle
   150 	*/
   151 	TAknLayoutRect iVerticalShadow;
   152 
   153 	/**
   154 	* Rectangle drawn around the edwin
   155 	*/
   156 	TAknLayoutRect iOutlineFrame;
   157 
   158 private:
   159     TInt iSpare;
   160 };
   161 
   162 /**
   163 * Implementation of the 6 line textual setting page. 
   164 * A multi-line edwin is displayed when the setting page is executing.
   165 * An externally held text descriptor is altered by user input
   166 */
   167 class CAknTextSettingPageExtension;
   168 
   169 class CAknTextSettingPage : public CAknEdwinSettingPage
   170 {
   171 public:
   172 
   173 // Flags to modify the behaviour of the editor
   174 	enum TAknTextSettingPageFlags
   175 	{
   176 	EZeroLengthNotOffered = 0x0,	// DEPRECATED. This enum preserved but with value 0
   177 	EPutCursorAtEnd = 0x0,			// DEPRECATED. This is already default so putting flag at beginning is more useful
   178 	EZeroLengthAllowed = 0x0000001,
   179 	ENoInitialSelection = 0x0000004,	// DEPRECATED and no longer used
   180 	EPutCursorAtBeginning = 0x0000008,	// DEPRECATED and no longer used
   181 	// Instructs the TextSettingPage not to override any of the Edwin's cursor and selection flags
   182 	EUseEdwinCursorAndSelectionFlags = 0x0000010, // DEPRECATED
   183 	EPredictiveTextEntryPermitted = 0x0020
   184 	};
   185 
   186 public:
   187 	/**
   188 	 * Simple constructor depending only on a single resource Id. Editor resource is given via
   189 	 * the link in the setting page resource.
   190 	 *
   191 	 * @param aSettingPageResourceId	Setting Page to use (if present)
   192 	 * @param aText						Reference to text for editing
   193 	 * @param aTextSettingPageFlags		option flags for miscellaneous things
   194 	 */
   195 	IMPORT_C CAknTextSettingPage(TInt aResourceID, TDes& aText, TInt aTextSettingPageFlags = 0 );
   196 	/**
   197 	 * Constructor that allows separate setting page and editor resources
   198 	 * 
   199 	 * This constructor allows the use of setting page using only the editor resource.  Other combinations are also possible
   200 	 *
   201 	 * In all cases the number (if supplied i.e. <> 0 ) is used.  
   202 	 *
   203 	 *		Editor Resource		Setting Page Resource
   204 	 *			present				present				Both are used (but text & number overridden)
   205 	 *			 = 0					present				Editor resource is used via SP resource (Effectively like the other constructor)
   206 	 *			present					= 0					Default Avkon SP resource if used + this editor resource
   207 	 *			 = 0					= 0					uses default resource for both SP and editor. This is OK if:
   208 	 *	 i) control type is present, 
   209 	 *  ii) a default resource exists ( OK for text, integer, date, time, duration )
   210 	 *
   211 	 * Note: The first argument is a TDesC* (rather than TDesC&) because the other constructor
   212 	 * cannot initialize such a member without allocation or having an internal dummy buffer.
   213 	 * Note that this buffer must be owned by the client until ExecuteLD has been called.
   214 	 *
   215 	 * Rules for text and numbers: The rules are the same for both:  (non-zero length) text or number other 
   216 	 * than EAknSettingPageNoOrdinalDisplayed if given in this constructor will not override resource 
   217 	 * (unless that is zero length or EAknSettingPageNoOrdinalDisplayed).  Note, however, that text or number given via the 
   218 	 * specific API for setting them, WILL override resource.
   219 	 * It is assumed that number from resource is very rare.  Special text is somewhat more likely.
   220 	 * 
   221 	 * @param aSettingTitleText	Text at top of setting pane; OWNED EXTERNALLY
   222 	 * @param aSettingNumber		Number at top left (if present)
   223 	 * @param aControlType			Determines the type constructed and how its resource is read
   224 	 * @param aEditorResourceId	Editor resource to use in the setting page (if present)
   225 	 * @param aSettingPageResourceId		Setting Page to use (if present)
   226 	 * @param aText					Reference to text for editing
   227 	 * @param aTextSettingPageFlags option flags for miscellaneous things
   228 	 */
   229 	IMPORT_C CAknTextSettingPage(	const TDesC* aSettingTitleText, 
   230 								TInt aSettingNumber, 
   231 								TInt aControlType,
   232 								TInt aEditorResourceId, 
   233 								TInt aSettingPageResourceId,
   234 								TDes& aText, 
   235 								TInt aTextSettingPageFlags = 0);
   236 
   237 	/**
   238 	* 2nd stage construction for this specific type.  Calls BaseConstructL in 
   239 	* CAknSettingPage, where the object is constructed from resource.
   240 	* 
   241 	* After calling this method, the contained editor is fully constructed and has its text set, 
   242 	* copied from the aText parameter of the constructor. 
   243 	* 
   244 	* This constructor can be called prior to a call to ExecuteLD in order to ensure 
   245 	* construction of the editor if API needs to be called on it prior to setting page launch.
   246 	* ExecuteLD will not attempt itself to do the construction a 2nd time.
   247 	* 
   248 	*/
   249 	IMPORT_C virtual void ConstructL();
   250 
   251     /**
   252     * From CCoeControl.     
   253     * Handles pointer events
   254     */
   255     IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
   256 
   257 
   258 protected:
   259 	/**
   260 	* C++ destructor
   261 	*
   262 	*/ 
   263 	IMPORT_C virtual ~CAknTextSettingPage();
   264 
   265 //
   266 // CAknSettingPage Framework implementations
   267 //
   268 protected:
   269 
   270 /**
   271 * Called immediately prior to activation of the dialog.  Framework routine for derived
   272 * classes.
   273 *
   274 */
   275 	IMPORT_C virtual void DynamicInitL();
   276 
   277 /**
   278 * Called when something has changed and the client's object needs to have its text updated
   279 *
   280 */
   281 	IMPORT_C virtual void UpdateSettingL();
   282 
   283 /**
   284 * Called when the user accepts the text and the setting page is about to be dismissed.  The latest value of the
   285 * text is written to the client's object
   286 */
   287 	IMPORT_C virtual void AcceptSettingL();
   288 
   289 /**
   290 * Called when the user rejects the setting.  
   291 * A backed up copy is used to restore the initial value
   292 *
   293 */
   294 	IMPORT_C virtual void RestoreOriginalSettingL();
   295 
   296 /**
   297  * From MCoeControlObserver:
   298  * Acts upon changes in the hosted control's state. If the EUpdateWhenChanged
   299  * flag is set, this updates the setting text.
   300  * 
   301  * @param	aControl	The control changing its state (not used)
   302  * @param	aEventType	The type of control event 
   303  */
   304 	IMPORT_C virtual void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType );	
   305 
   306 
   307 /**
   308  * Framework method to set the validity of the data
   309  * This is called when the data changes.
   310  *
   311  */
   312 	IMPORT_C virtual void CheckAndSetDataValidity();
   313 
   314 /**
   315 * This method copies out the text from the editor into the client's descriptor
   316 *
   317 */
   318 	IMPORT_C virtual void UpdateTextL();
   319 	
   320 /**
   321 * Update the CBA. This should be called after a control state change in case 
   322 * there has been a change in data validity.
   323 *
   324 */
   325 	IMPORT_C virtual void UpdateCbaL();
   326 
   327 /**
   328 * Framework method to determine if it is OK to exit the setting page.
   329 * Derived classes may check for valid data before allowing the dismissal of the 
   330 * setting page.
   331 * 
   332 *
   333 *
   334 * @param	aAccept ETrue if the user has indicated to accept the setting page; EFalse otherwise
   335 * @return	TBool	a value indicating whether the setting page should be dismissed
   336 */
   337     IMPORT_C virtual TBool OkToExitL(TBool aAccept);
   338 
   339 /** 
   340 * This routine routes the keys to the editor. 
   341 * However, if the menu is showing, then events are sent to the menu. 
   342 *
   343 * @param	aKeyEvent	event information	
   344 * @param	aType		type of event being handled
   345 *
   346 */
   347 	IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType);
   348 
   349 
   350 /**
   351  * Reserved methods for CAknSettingPage hierarchy
   352  */ 
   353 private: 
   354 	IMPORT_C virtual void CAknSettingPage_Reserved_1();
   355 	IMPORT_C virtual void CAknSettingPage_Reserved_2();
   356 
   357 // 
   358 // From CCoeControl
   359 //
   360 
   361 protected:
   362 
   363 /**
   364 * From CCoeControl
   365 * This routine is called as part of the set-up of the control.  It is the place to put
   366 * the layout code. 
   367 *
   368 */
   369 	IMPORT_C virtual void SizeChanged();
   370 
   371 /**
   372  * Writes the internal state of the control and its components to aStream.
   373  * Does nothing in release mode.
   374  * Designed to be overidden and base called by subclasses.
   375  *
   376  * @param	aWriteSteam		A connected write stream
   377  */	
   378 	IMPORT_C virtual void WriteInternalStateL(RWriteStream& aWriteStream) const;
   379 
   380 private:
   381 /**
   382  *	Reserved method derived from CCoeControl
   383  */
   384 	IMPORT_C virtual void Reserved_2();
   385 
   386 private:
   387     /**
   388     * From CAknControl
   389     */
   390     IMPORT_C void* ExtensionInterface( TUid aInterface );
   391 
   392 /**
   393  * Reserved method from CAknEdwinSettingPage
   394  *
   395  */
   396 	IMPORT_C virtual void CAknEdwinSettingPage_Reserved_1();
   397 
   398 private: 
   399     // restarts timer that blocks Ok button for the period FEP may reject the edit
   400     void RestartMultitapWaitTimer();
   401 
   402 private:
   403 	HBufC* iBackupText;
   404 	TDes& iText;
   405 	TInt iTextSettingPageFlags;
   406 	CAknTextSettingPageExtension* iExtension; 
   407 	};
   408 
   409 
   410 /**
   411  * Setting page specialized for display of CAknIntegerEdwin
   412  *
   413  */
   414 class CAknIntegerSettingPage : public CAknEdwinSettingPage
   415 {
   416 public:
   417 
   418 // Flags to modify the behaviour of the editor
   419 	enum TAknIntegerSettingPageFlags
   420 	{
   421 	EInvalidValueNotOffered = 0x0,
   422 	EEmptyValueAllowed = 0x0000001,
   423 	EInvalidValueAllowed = 0x0000002,
   424 	ENoInitialSelection = 0x0000004,
   425 	EPutCursorAtBeginning = 0x0000008
   426 	};
   427 
   428 public:
   429 	IMPORT_C CAknIntegerSettingPage(TInt aResourceID, TInt& aValue, TInt aTextSettingPageFlags = 0 );
   430 	/**
   431 	 * Constructor that allows separate setting page and editor resources
   432 	 * 
   433 	 * This constructor allows the use of setting page using only the editor resource.  Other combinations are also possible
   434 	 *
   435 	 * In all cases the number (if supplied i.e. <> 0 ) is used.  
   436 	 *
   437 	 *		Editor Resource		Setting Page Resource
   438 	 *			present				present				Both are used (but text & number overridden)
   439 	 *			 = 0					present				Editor resource is used via SP resource (Effectively like the other constructor)
   440 	 *			present				= 0					Default Avkon SP resource if used + this editor resource
   441 	 *			 = 0					= 0					uses default resource for both SP and editor. This is OK if:
   442 	 *	 i) control type is present, 
   443 	 *  ii) a default resource exists ( OK for text, integer, date, time, duration )
   444 	 *
   445 	 * Note: The first argument is a TDesC* (rather than TDesC&) because the other constructor
   446 	 * cannot initialize such a member without allocation or having an internal dummy buffer.
   447 	 *
   448 	 * Rules for text and numbers: The rules are the same for both:  (non-zero length) text or number other 
   449 	 * than EAknSettingPageNoOrdinalDisplayed if given in this constructor will not override resource 
   450 	 * (unless that is zero length or EAknSettingPageNoOrdinalDisplayed).  Note, however, that text or number given via the 
   451 	 * specific API for setting them, WILL override resource.
   452 	 * It is assumed that number from resource is very rare.  Special text is somewhat more likely.
   453 	 * 
   454 	 * @param aSettingTitleText	Text at top of setting pane; OWNED EXTERNALLY
   455 	 * @param aSettingNumber		Number at top left (if present)
   456 	 * @param aControlType			Determines the type constructed and how its resource is read
   457 	 * @param aEditorResourceId	Editor resource to use in the setting page (if present)
   458 	 * @param aSettingPageResourceId		Setting Page to use (if present)
   459 	 * @param aValue					Reference to integer value for editing
   460 	 * @param aIntegerSettingPageFlags option flags for miscellaneous things
   461 	 */
   462 	IMPORT_C CAknIntegerSettingPage(	const TDesC* aSettingTitleText, 
   463 								TInt aSettingNumber, 
   464 								TInt aControlType,
   465 								TInt aEditorResourceId, 
   466 								TInt aSettingPageResourceId,
   467 								TInt& aValue, 
   468 								TInt aIntegerSettingPageFlags = 0);
   469 
   470 	/**
   471 	* 2nd stage construction for this specific type.  Call BaseConstructL in 
   472 	* CAknSettingPage, where the object is constructed from resource.
   473 	*/
   474 	IMPORT_C virtual void ConstructL();
   475 
   476 	/** 
   477 	* Type-specific access to the hosted editor
   478 	*
   479 	* @return CAknIntegerEdwin*		pointer to the current hosted editor
   480 	*/
   481 	IMPORT_C CAknIntegerEdwin* IntegerEditorControl();
   482 
   483     /**
   484     * From CCoeControl.     
   485     * Handles pointer events
   486     */
   487     IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
   488 
   489 //
   490 // Framework methods from CAknSettingPage
   491 //
   492 protected:
   493 
   494 /**
   495 * Called immediately prior to activation of the dialog.  Framework routine for derived
   496 * classes.
   497 *
   498 */
   499 	IMPORT_C virtual void DynamicInitL();
   500 
   501 /**
   502 * Called when something has changed and the client's object needs to have its value updated
   503 *
   504 */
   505 	IMPORT_C virtual void UpdateSettingL();
   506 
   507 
   508 /**
   509 * Called when the user rejects the setting.  A backup copy may need to be restored if UpdateWhenChanged flag was set
   510 *
   511 */
   512 	IMPORT_C virtual void RestoreOriginalSettingL();
   513 
   514 /**
   515  * Framework method to set the validity of the data
   516  * This is called when the data changes.
   517  * May be over-ridden to change the validation rules.
   518  *
   519  */
   520 	IMPORT_C virtual void CheckAndSetDataValidity();
   521 
   522 /** 
   523  * This framework method is used to update the contents of the CBA in a custom way.
   524  * Some setting page classes implement a degree of validation and will implement this.
   525  * Derived classes should ensure that this is being called frequently enough for their
   526  * purposes.
   527  */
   528 	IMPORT_C virtual void UpdateCbaL();
   529 
   530 /**
   531  * Reserved methods for CAknSettingPage hierarchy
   532  */ 
   533 private: 
   534 	IMPORT_C virtual void CAknSettingPage_Reserved_1();
   535 	IMPORT_C virtual void CAknSettingPage_Reserved_2();
   536 
   537 
   538 
   539 //
   540 // From MEikControlObserver
   541 //
   542 
   543 protected:
   544 
   545 /**
   546  * From MCoeControlObserver:
   547  * Acts upon changes in the hosted control's state. 
   548  * 
   549  * The implementation of this class is trivial and should be able to be
   550  * safely re-implemented in directly client-derived classes. 
   551  * For non-base setting page classes, a call to the base class should be made
   552  *
   553  * @param	aControl	The control changing its state (not used)
   554  * @param	aEventType	The type of control event 
   555  */
   556 	IMPORT_C virtual void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType );	
   557 
   558 //
   559 // From CCoeControl
   560 //
   561 protected:
   562 
   563 /**
   564 * From CCoeControl
   565 * This routine is called as part of the set-up of the control.  It is the place to put
   566 * layout code. 
   567 *
   568 */
   569 	IMPORT_C virtual void SizeChanged();
   570 
   571 
   572 /**
   573  * Writes the internal state of the control and its components to aStream.
   574  * Does nothing in release mode.
   575  * Designed to be overidden and base called by subclasses.
   576  *
   577  * @param	aWriteSteam		A connected write stream
   578  */	
   579 	IMPORT_C virtual void WriteInternalStateL(RWriteStream& aWriteStream) const;
   580 
   581 private: 
   582 /**
   583  *	Reserved method derived from CCoeControl
   584  */
   585 	IMPORT_C virtual void Reserved_2();
   586 
   587 private:
   588     /**
   589     * From CAknControl
   590     */
   591     IMPORT_C void* ExtensionInterface( TUid aInterface );
   592 
   593 private:
   594 
   595 /**
   596  * Reserved method from CAknEdwinSettingPage
   597  *
   598  */
   599 	IMPORT_C virtual void CAknEdwinSettingPage_Reserved_1();
   600 
   601 private:
   602 	TInt iBackupValue;
   603 	TInt& iValue;
   604 	TInt iIntegerSettingPageFlags;
   605 	TInt iSpare_1; 
   606 };
   607 
   608 
   609 #endif