textrendering/texthandling/inc/FLDBASE.H
changeset 0 1fb32624e06b
equal deleted inserted replaced
-1:000000000000 0:1fb32624e06b
       
     1 /*
       
     2 * Copyright (c) 1997-2009 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 "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __FLDBASE_H__
       
    20 #define __FLDBASE_H__
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <e32base.h>
       
    24 #include <s32stor.h>
       
    25 
       
    26 // Classes defined:
       
    27 class CTextField;
       
    28 class MTextFieldFactory;
       
    29 
       
    30 
       
    31 
       
    32 
       
    33 class CTextField : public CBase
       
    34 /** 
       
    35 Abstract class: derive from this to instantiate a particular type of field (eg date etc)
       
    36 Abstract base class for all field types.
       
    37 
       
    38 A field contains information which relates to a text object and can be automatically 
       
    39 updated, e.g. page number or current date and time. Fields must implement 
       
    40 the pure virtual functions defined in this class, including Value() which 
       
    41 should calculate and return the field's new value, and Type() which returns 
       
    42 the field's type UID. The type UID identifies the field type to the field 
       
    43 factory (see class MTextFieldFactory). 
       
    44 @publishedAll
       
    45 @released
       
    46 */
       
    47 	{
       
    48 public:
       
    49 	IMPORT_C virtual TStreamId StoreL(CStreamStore& aStore)const; // calls ExternalizeL()
       
    50 	IMPORT_C virtual void RestoreL(const CStreamStore& aStore,TStreamId aId); // calls InternalizeL()
       
    51 	//
       
    52 	// Should be replaced by concrete derived classes.
       
    53 	IMPORT_C virtual void ExternalizeL(RWriteStream& aStream)const; // Externalize state info for the field
       
    54     /** Internalises the field data. Called by RestoreL().
       
    55 	
       
    56 	@param aStream Stream from which the field data should be internalised. */
       
    57 	virtual void InternalizeL(RReadStream& aStream)=0;
       
    58 	//
       
    59 	/** Sets aValueText to the current field value if the buffer is large enough. If 
       
    60 	not, aValueText is not changed, and the function returns the length which 
       
    61 	is required to hold the field's value.
       
    62 	
       
    63 	@param aValueText Descriptor which on return contains the field's updated 
       
    64 	value. 
       
    65 	@return Zero on success, otherwise, the length of the buffer which is required 
       
    66 	to hold the field's updated value. */
       
    67 	virtual TInt Value(TPtr& aValueText)=0; 
       
    68 	//	
       
    69 	/** Returns the field's type UID.
       
    70 	
       
    71 	@return The field's type UID. */
       
    72 	virtual TUid Type()const=0;
       
    73 	};
       
    74 
       
    75 
       
    76  
       
    77 
       
    78 class MTextFieldFactory
       
    79 /** 
       
    80 Abstract class that should be derived from by any application that wishes to support fields
       
    81 Abstract base class for field factories.
       
    82 
       
    83 To use fields in editable text,
       
    84 
       
    85 1) Define a field factory class (derived from MTextFieldFactory) that implements 
       
    86 NewFieldL().
       
    87 
       
    88 2) Create an instance of the field factory and set this to be the editable 
       
    89 text object's field factory (see CPlainText::SetFieldFactory(), or you can 
       
    90 specify a field factory in the text object 's NewL()).
       
    91 
       
    92 3) Create a new field (CPlainText::NewTextFieldL()), specifying the field 
       
    93 type UID (the built in field type UID values are defined in flddef.h). This 
       
    94 calls the factory's NewFieldL() function.
       
    95 
       
    96 4) Insert the field into the text object (CPlainText::InsertFieldL()).
       
    97 
       
    98 5) Evaluate the field (CPlainText::UpdateFieldL()) and then re-evaluate when 
       
    99 required. 
       
   100 @publishedAll
       
   101 @released
       
   102 */
       
   103 	{
       
   104 public:
       
   105 	
       
   106 	/** Implementations of this function should create a field of the type specified, 
       
   107 	returning NULL if the field type is not recognised or supported.
       
   108 	
       
   109 	@param aFieldType The field's type UID. 
       
   110 	@return Pointer to the new text field, or NULL if the factory does not recognise 
       
   111 	or support the field type. */
       
   112 	virtual CTextField* NewFieldL(TUid aFieldType)=0; 
       
   113 	// Creates a field of the type specified
       
   114 	// Returns NULL if it does not recognise/support the field type
       
   115 	};
       
   116 
       
   117 
       
   118 #endif