epoc32/include/bacell.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/bacell.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/bacell.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,227 @@
     1.4 -bacell.h
     1.5 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +// All rights reserved.
     1.7 +// This component and the accompanying materials are made available
     1.8 +// 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
     1.9 +// which accompanies this distribution, and is available
    1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +//
    1.12 +// Initial Contributors:
    1.13 +// Nokia Corporation - initial contribution.
    1.14 +//
    1.15 +// Contributors:
    1.16 +//
    1.17 +// Description:
    1.18 +//
    1.19 +
    1.20 +// Written by DanH, Sept 1995
    1.21 +#if !defined(__BACELL_H__)
    1.22 +#define __BACELL_H__
    1.23 +
    1.24 +#if !defined(__E32DEF_H_)
    1.25 +#include <e32def.h>
    1.26 +#endif
    1.27 +
    1.28 +#if !defined(__S32STRM_H__)
    1.29 +#include <s32strm.h>
    1.30 +#endif
    1.31 +
    1.32 +//class RReadStream;
    1.33 +//class RWriteStream;
    1.34 +
    1.35 +class TCellRef
    1.36 +/** 
    1.37 +Identifies a cell by row and column number. 
    1.38 +@publishedAll
    1.39 +@released
    1.40 +*/
    1.41 +	{
    1.42 +public:
    1.43 +	inline TCellRef();
    1.44 +	inline TCellRef(TInt aRow,TInt aCol);
    1.45 +
    1.46 +	inline TBool operator==(const TCellRef& aCell) const;
    1.47 +	inline TBool operator!=(const TCellRef& aCell) const;
    1.48 +
    1.49 +	inline TCellRef& operator+=(const TCellRef& aCell);
    1.50 +	inline TCellRef& operator-=(const TCellRef& aCell);
    1.51 +
    1.52 +	IMPORT_C void Offset(TInt aRowOffset,TInt aColOffset);
    1.53 +//
    1.54 +	IMPORT_C void InternalizeL(RReadStream& aStream);
    1.55 +	inline void ExternalizeL(RWriteStream& aStream) const;
    1.56 +public:
    1.57 +	/** The row number. */
    1.58 +	TInt iRow;
    1.59 +	/** The column number. */
    1.60 +	TInt iCol;
    1.61 +	};
    1.62 +
    1.63 +/** 
    1.64 +@publishedAll
    1.65 +@released
    1.66 +*/
    1.67 +IMPORT_C TCellRef operator+(const TCellRef& aLeft,const TCellRef& aRight);
    1.68 +IMPORT_C TCellRef operator-(const TCellRef& aLeft,const TCellRef& aRight);
    1.69 +
    1.70 +inline TCellRef::TCellRef()
    1.71 +	/** Default constructor.
    1.72 +	
    1.73 +	The object's row and column number are undefined. */
    1.74 +	{}
    1.75 +inline TCellRef::TCellRef(TInt aRow,TInt aCol)
    1.76 +    : iRow(aRow),iCol(aCol)
    1.77 +	/** Constructor taking a row and column number.
    1.78 +	
    1.79 +	@param aRow The row number.
    1.80 +	@param aCol The column number. */
    1.81 +	{}
    1.82 +inline TBool TCellRef::operator==(const TCellRef& aCell) const
    1.83 +	/** Compares this cell with the specified cell for equality.
    1.84 +	
    1.85 +	@param aCell The cell to be compared.
    1.86 +	@return ETrue, if the row numbers are the same and column numbers are 
    1.87 +	the same. */
    1.88 +	{return aCell.iRow==iRow && aCell.iCol==iCol;}
    1.89 +inline TBool TCellRef::operator!=(const TCellRef& aCell) const
    1.90 +	/** Compares this cell with the specified cell for inequality.
    1.91 +	
    1.92 +	@param aCell The cell to be compared.
    1.93 +	@return ETrue, if the row numbers are different or the column numbers are 
    1.94 +	different. */
    1.95 +	{return aCell.iRow!=iRow || aCell.iCol!=iCol;}
    1.96 +inline TCellRef& TCellRef::operator+=(const TCellRef& aCell)
    1.97 +	/** Adds the specified cell to this cell.
    1.98 +	
    1.99 +	Addition is the process of adding the specified cell's row and column 
   1.100 +	numbers to this cell's row and column numbers respectively.
   1.101 +	
   1.102 +	@param aCell The cell to be added.
   1.103 +	@return A reference to this cell object. */
   1.104 +	{Offset(aCell.iRow,aCell.iCol);return *this;}
   1.105 +inline TCellRef& TCellRef::operator-=(const TCellRef& aCell)
   1.106 +	/** Subtracts the specified cell from this cell.
   1.107 +	
   1.108 +	Subtraction is the process of subtracting the specified cell's row and 
   1.109 +	column numbers from this cell's row and column numbers respectively.
   1.110 +	
   1.111 +	@param aCell The cell to be subtracted.
   1.112 +	@return A reference to this cell object. */
   1.113 +	{Offset(-aCell.iRow,-aCell.iCol);return *this;}
   1.114 +inline void TCellRef::ExternalizeL(RWriteStream& aStream) const
   1.115 +	/** Externalises an object of this class to a write stream.
   1.116 +	
   1.117 +	The presence of this function means that the standard templated operator<<() 
   1.118 +	can be used to externalise objects of this class. 
   1.119 +	
   1.120 +	@param aStream Stream to which the object should be externalised. */
   1.121 +	{aStream.WriteInt32L(iRow);aStream.WriteInt32L(iCol);}
   1.122 +
   1.123 +
   1.124 +class TRangeRef
   1.125 +/** 
   1.126 +Identifies a range of cells by start and end cell references.
   1.127 +The range is inclusive of both the start and end cells.
   1.128 +@see TCellRef
   1.129 +@publishedAll
   1.130 +@released
   1.131 +*/
   1.132 +	{
   1.133 +public:
   1.134 +	inline TRangeRef();
   1.135 +	inline TRangeRef(const TCellRef& aFrom,const TCellRef& aTo);
   1.136 +	inline TRangeRef(TInt aFromRow,TInt aFromCol,TInt aToRow,TInt aToCol);
   1.137 +
   1.138 +	IMPORT_C TBool operator==(const TRangeRef& aRange) const;
   1.139 +	inline TBool operator!=(const TRangeRef& aRange) const;
   1.140 +
   1.141 +	inline void SetRange(const TCellRef& aFrom,const TCellRef& aTo);
   1.142 +	inline void SetRange(TInt aFromRow,TInt aFromCol,TInt aToRow,TInt aToCol);
   1.143 +	inline TInt NoRows() const;
   1.144 +	inline TInt NoCols() const;
   1.145 +	IMPORT_C TInt NoCells() const;
   1.146 +	IMPORT_C TBool Contains(const TCellRef& aCell) const;
   1.147 +	IMPORT_C void InternalizeL(RReadStream& aStream);
   1.148 +	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   1.149 +public:
   1.150 +	/** The start cell. */
   1.151 +	TCellRef	iFrom;
   1.152 +	/** The end cell. */
   1.153 +	TCellRef	iTo;
   1.154 +public:
   1.155 +	class TIter;	// defined outside TRangeRef class as contains TRangeRef
   1.156 +	};
   1.157 +class TRangeRef::TIter
   1.158 +/**
   1.159 +@publishedAll
   1.160 +@released
   1.161 +*/
   1.162 +	{
   1.163 +public:
   1.164 +	IMPORT_C TIter(const TRangeRef& aRangeRef);
   1.165 +	IMPORT_C TBool operator++();
   1.166 +	inline TBool InRange() const;
   1.167 +public:
   1.168 +	TCellRef	iCurrent;
   1.169 +private:
   1.170 +	TRangeRef	iRange;
   1.171 +	};
   1.172 +
   1.173 +
   1.174 +inline TRangeRef::TRangeRef()
   1.175 +	/** Default constructor.
   1.176 +	
   1.177 +	The object's start cell and end cell are undefined. */
   1.178 +	{}
   1.179 +inline TRangeRef::TRangeRef(const TCellRef& aFrom,const TCellRef& aTo)
   1.180 +	: iFrom(aFrom),iTo(aTo)
   1.181 +	/** Constructor taking a start and end cell.
   1.182 +	
   1.183 +	@param aFrom The start cell.
   1.184 +	@param aTo The end cell. */
   1.185 +	{}
   1.186 +inline TRangeRef::TRangeRef(TInt aFromRow,TInt aFromCol,TInt aToRow,TInt aToCol)
   1.187 +	: iFrom(aFromRow,aFromCol),iTo(aToRow,aToCol)
   1.188 +	/** Constructor taking a start row and start column number, and an end row and 
   1.189 +	end column number.
   1.190 +	
   1.191 +	@param aFromRow The start row number.
   1.192 +	@param aFromCol The start column number.
   1.193 +	@param aToRow The end row number.
   1.194 +	@param aToCol The end column number. */
   1.195 +	{}
   1.196 +inline void TRangeRef::SetRange(const TCellRef& aFrom,const TCellRef& aTo)
   1.197 +	/** Sets the cell range to the specified cells.
   1.198 +	
   1.199 +	@param aFrom The start cell for the range.
   1.200 +	@param aTo The end cell for the range. */
   1.201 +	{iFrom=aFrom;iTo=aTo;}
   1.202 +inline void TRangeRef::SetRange(TInt aFromRow,TInt aFromCol,TInt aToRow,TInt aToCol)
   1.203 +	/** Sets the cell range to the specified start row and column, and end row 
   1.204 +	and column.
   1.205 +	
   1.206 +	@param aFromRow The start row number.
   1.207 +	@param aFromCol The start column number.
   1.208 +	@param aToRow The end row number.
   1.209 +	@param aToCol The end column number. */
   1.210 +	{iFrom.iRow=aFromRow;iFrom.iCol=aFromCol;iTo.iRow=aToRow;iTo.iCol=aToCol;}
   1.211 +inline TBool TRangeRef::operator!=(const TRangeRef& aRange) const
   1.212 +	/** Compares this cell range with the specified cell range for inequality.
   1.213 +	
   1.214 +	@param aRange The cell to be compared.
   1.215 +	@return ETrue, if the start cells are different or the end cells are 
   1.216 +	different. */
   1.217 +	{return !operator==(aRange);}
   1.218 +inline TInt TRangeRef::NoRows() const
   1.219 +	/** Gets the number of rows represented by the range.
   1.220 +	
   1.221 +	@return The number of rows. */
   1.222 +	{return iTo.iRow - iFrom.iRow + 1;}
   1.223 +inline TInt TRangeRef::NoCols() const
   1.224 +	/** Gets the number of columns represented by the range.
   1.225 +	
   1.226 +	@return The number of columns. */
   1.227 +	{return iTo.iCol - iFrom.iCol + 1;}
   1.228 +inline TBool TRangeRef::TIter::InRange() const
   1.229 +	{return iRange.Contains(iCurrent);}
   1.230 +
   1.231 +#endif