sl@0: /* sl@0: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #ifndef __FLDBLTIN_H__ sl@0: #define __FLDBLTIN_H__ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: sl@0: // Classes declared in this file sl@0: class MFieldPageNumInfo; sl@0: class MFieldNumPagesInfo; sl@0: class MFieldFileNameInfo; sl@0: // the built-in field types sl@0: class CDateTimeField; sl@0: class CPageNumField; sl@0: class CNumPagesField; sl@0: class CFileNameField; sl@0: class TRomanNumeral; sl@0: // sl@0: // Classes referenced sl@0: class RReadStream; sl@0: class RWriteStream; sl@0: sl@0: sl@0: sl@0: /** sl@0: Specifies the mixin protocol for evaluating a current page number field. sl@0: sl@0: You should implement the UpdateFieldPageNum() function in a concrete derived sl@0: class, then pass an object of the class to the page number field (using CPageNumField::SetPageNumInfo()) sl@0: before the field can be evaluated. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class MFieldPageNumInfo sl@0: { sl@0: public: sl@0: sl@0: sl@0: /** Implementations of this function should return the current page number. sl@0: sl@0: @return The page number. */ sl@0: virtual TInt UpdateFieldPageNum()const=0; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Specifies the mixin protocol for evaluating a total number of pages field. sl@0: sl@0: You should implement the UpdateFieldNumPages() function in a concrete derived sl@0: class, then pass an object of the class to the number of pages field (using sl@0: CNumPagesField::SetNumPagesInfo()) before the field can be evaluated. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class MFieldNumPagesInfo sl@0: { sl@0: public: sl@0: sl@0: sl@0: /** Implementations of this function should return the number of pages in the current sl@0: document. sl@0: sl@0: @return The total number of pages. */ sl@0: virtual TInt UpdateFieldNumPages()const=0; sl@0: }; sl@0: sl@0: sl@0: sl@0: /** sl@0: Specifies the mixin protocol for evaluating a filename field. sl@0: sl@0: You should implement the UpdateFieldFileName() function in a concrete derived sl@0: class, then pass an object of the derived class to the filename field (using sl@0: CFileNameField::SetFileNameInfo()) before the field can be evaluated. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class MFieldFileNameInfo sl@0: { sl@0: public: sl@0: sl@0: sl@0: /** Implementations of this function should set aValueText to the current document's sl@0: filename, if the buffer is large enough. If not, the function should return sl@0: the length which is required to hold the filename. sl@0: sl@0: @param aValueText Descriptor which on return contains the document's filename. sl@0: sl@0: @return Zero if aValueText is long enough to hold the filename. Otherwise, sl@0: the length of the buffer which is required to hold the filename. */ sl@0: virtual TInt UpdateFieldFileName(TPtr& aValueText)const=0; sl@0: }; sl@0: sl@0: sl@0: sl@0: /** sl@0: A date/time field. sl@0: sl@0: This may contain any or all components of the date and time, and can be formatted sl@0: in a variety of ways. It stores a format string, which is used by the Value() sl@0: function to format the current date/time. For information on date/time formatting, sl@0: see TTime::FormatL(). sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CDateTimeField : public CTextField sl@0: { sl@0: public: sl@0: IMPORT_C CDateTimeField(); sl@0: IMPORT_C void SetFormat(const TDesC& aFormat); sl@0: // from TTextField sl@0: IMPORT_C virtual TInt Value(TPtr& aValueText); sl@0: IMPORT_C virtual void InternalizeL(RReadStream& aStream); sl@0: IMPORT_C virtual void ExternalizeL(RWriteStream& aStream)const; sl@0: // sl@0: // Getters sl@0: IMPORT_C const TDesC& FormatString()const; sl@0: IMPORT_C TUid Type()const; sl@0: protected: sl@0: TBuf<64> iFormatString; sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Stores a style for displaying the value of numeric fields. sl@0: sl@0: This style is used when converting the integer value of numeric fields into sl@0: a descriptor for display in another format, e.g. Arabic, Roman, alphabetic. sl@0: This is the base class for the numeric fields, CPageNumField and CNumPagesField. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CPageFieldBase : public CTextField sl@0: { sl@0: public: sl@0: /** Numeric style */ sl@0: enum TNumberStyle { sl@0: /** Arabic numeral, e.g. 1, 2, 3. */ sl@0: EArabic, // 1,2,3 sl@0: /** Upper case Roman numeral, e.g. I, II, III. */ sl@0: ERomanUpper, // I,II,III sl@0: /** Lower case Roman numeral, e.g. i, ii, iii. */ sl@0: ERomanLower, // i,ii,iii sl@0: /** Upper case alphabetic. */ sl@0: EAlphabeticUpper, // A,B,C sl@0: /** Lower case alphabetic. */ sl@0: EAlphabeticLower // a,b,c sl@0: }; sl@0: public: sl@0: sl@0: /** Sets the numeric style. sl@0: sl@0: @param aStyle The numeric style. */ sl@0: inline void SetNumberStyle(TNumberStyle aStyle) { iStyle = aStyle; } sl@0: // from TTextField sl@0: IMPORT_C void InternalizeL(RReadStream& aStream); sl@0: IMPORT_C void ExternalizeL(RWriteStream& aStream)const; sl@0: // sl@0: // Getters sl@0: IMPORT_C TNumberStyle NumberStyle()const; sl@0: protected: sl@0: TInt InsertValue(TPtr& aValueText,TInt aValue); sl@0: protected: sl@0: TNumberStyle iStyle; sl@0: }; sl@0: sl@0: sl@0: sl@0: /** sl@0: A field which evaluates to the current page number in the document. sl@0: sl@0: Before the page number field can be evaluated, it must be passed a pointer sl@0: to an object which implements the UpdateFieldPageNum() function. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CPageNumField : public CPageFieldBase sl@0: { sl@0: public: sl@0: /** Sets the object which implements UpdateFieldPageNum(), to get the current page sl@0: number. SetPageNumInfo() must be called before the page number field can be sl@0: evaluated. sl@0: sl@0: @param aInfo Pointer to an object which implements UpdateFieldPageNum(). */ sl@0: inline void SetPageNumInfo(MFieldPageNumInfo* aInfo) { iPageNumInfo=aInfo; } sl@0: // from TTextField sl@0: IMPORT_C TInt Value(TPtr& aValueText); sl@0: IMPORT_C TUid Type()const; sl@0: protected: sl@0: MFieldPageNumInfo* iPageNumInfo; sl@0: }; sl@0: sl@0: sl@0: sl@0: /** sl@0: A field which evaluates to the number of pages in the document. sl@0: sl@0: Before the number of pages field can be evaluated, it must be passed a pointer sl@0: to an object which implements the UpdateFieldNumPages() function. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CNumPagesField : public CPageFieldBase sl@0: { sl@0: public: sl@0: /** Sets the object which implements UpdateFieldNumPages(), to get the number of sl@0: pages in the document. SetNumPagesInfo() must be called before the number sl@0: of pages field can be evaluated. sl@0: sl@0: @param aInfo Pointer to an object which implements UpdateFieldNumPages(). */ sl@0: inline void SetNumPagesInfo(MFieldNumPagesInfo* aInfo) { iNumPagesInfo=aInfo; } sl@0: // from TTextField sl@0: IMPORT_C TInt Value(TPtr& aValueText); sl@0: IMPORT_C TUid Type()const; sl@0: protected: sl@0: MFieldNumPagesInfo* iNumPagesInfo; sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: A filename field. sl@0: sl@0: This is a field which evaluates to the filename of the current document. Before sl@0: the filename field can be evaluated, it must be passed a pointer to an object sl@0: which implements the UpdateFieldFileName() function. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CFileNameField : public CTextField sl@0: { sl@0: public: sl@0: /** Sets the object which implements the UpdateFieldFileName() function, to get sl@0: the current document's filename. SetFileNameInfo() must be called before the sl@0: filename field can be evaluated. sl@0: sl@0: @param aInfo Pointer to an object which implements the UpdateFieldFileName() sl@0: function. */ sl@0: inline void SetFileNameInfo(MFieldFileNameInfo* aInfo) { iFileNameInfo=aInfo; } sl@0: // from TTextField sl@0: IMPORT_C virtual TStreamId StoreL(CStreamStore& aStore)const; // returns KNullStreamId sl@0: IMPORT_C virtual void RestoreL(const CStreamStore& aStore,TStreamId aId); // does nothing. sl@0: IMPORT_C virtual TInt Value(TPtr& aValueText); sl@0: sl@0: sl@0: /** Overrides the base class method to do nothing, because this class has no persistent sl@0: data. */ sl@0: inline virtual void InternalizeL(RReadStream& /*aStream*/) {}; // stream the formatting sl@0: IMPORT_C TUid Type()const; sl@0: protected: sl@0: MFieldFileNameInfo* iFileNameInfo; sl@0: }; sl@0: sl@0: sl@0: #endif