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