1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // 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
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
25 class MTextFieldFactory;
30 class CTextField : public CBase
32 Abstract class: derive from this to instantiate a particular type of field (eg date etc)
33 Abstract base class for all field types.
35 A field contains information which relates to a text object and can be automatically
36 updated, e.g. page number or current date and time. Fields must implement
37 the pure virtual functions defined in this class, including Value() which
38 should calculate and return the field's new value, and Type() which returns
39 the field's type UID. The type UID identifies the field type to the field
40 factory (see class MTextFieldFactory).
46 IMPORT_C virtual TStreamId StoreL(CStreamStore& aStore)const; // calls ExternalizeL()
47 IMPORT_C virtual void RestoreL(const CStreamStore& aStore,TStreamId aId); // calls InternalizeL()
49 // Should be replaced by concrete derived classes.
50 IMPORT_C virtual void ExternalizeL(RWriteStream& aStream)const; // Externalize state info for the field
51 /** Internalises the field data. Called by RestoreL().
53 @param aStream Stream from which the field data should be internalised. */
54 virtual void InternalizeL(RReadStream& aStream)=0;
56 /** Sets aValueText to the current field value if the buffer is large enough. If
57 not, aValueText is not changed, and the function returns the length which
58 is required to hold the field's value.
60 @param aValueText Descriptor which on return contains the field's updated
62 @return Zero on success, otherwise, the length of the buffer which is required
63 to hold the field's updated value. */
64 virtual TInt Value(TPtr& aValueText)=0;
66 /** Returns the field's type UID.
68 @return The field's type UID. */
69 virtual TUid Type()const=0;
75 class MTextFieldFactory
77 Abstract class that should be derived from by any application that wishes to support fields
78 Abstract base class for field factories.
80 To use fields in editable text,
82 1) Define a field factory class (derived from MTextFieldFactory) that implements
85 2) Create an instance of the field factory and set this to be the editable
86 text object's field factory (see CPlainText::SetFieldFactory(), or you can
87 specify a field factory in the text object 's NewL()).
89 3) Create a new field (CPlainText::NewTextFieldL()), specifying the field
90 type UID (the built in field type UID values are defined in flddef.h). This
91 calls the factory's NewFieldL() function.
93 4) Insert the field into the text object (CPlainText::InsertFieldL()).
95 5) Evaluate the field (CPlainText::UpdateFieldL()) and then re-evaluate when
103 /** Implementations of this function should create a field of the type specified,
104 returning NULL if the field type is not recognised or supported.
106 @param aFieldType The field's type UID.
107 @return Pointer to the new text field, or NULL if the factory does not recognise
108 or support the field type. */
109 virtual CTextField* NewFieldL(TUid aFieldType)=0;
110 // Creates a field of the type specified
111 // Returns NULL if it does not recognise/support the field type