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