lowlevellibsandfws/apputils/src/BACELL.CPP
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <e32std.h>
       
    17 #include <bacell.h>
       
    18 
       
    19 EXPORT_C TCellRef operator+(const TCellRef& aLeft,const TCellRef& aRight)
       
    20 	{
       
    21 	return TCellRef(aLeft.iRow+aRight.iRow,aLeft.iCol+aRight.iCol);
       
    22 	}
       
    23 
       
    24 EXPORT_C TCellRef operator-(const TCellRef& aLeft,const TCellRef& aRight)
       
    25 	{
       
    26 	return TCellRef(aLeft.iRow-aRight.iRow,aLeft.iCol-aRight.iCol);
       
    27 	}
       
    28 
       
    29 EXPORT_C void TCellRef::Offset(TInt aRowOffset,TInt aColOffset)
       
    30 /** Adds the specified row and column numbers to this cell's row and column values.
       
    31 
       
    32 @param aRowOffset The row number to be added. The value may be positive, zero 
       
    33 or negative.
       
    34 @param aColOffset The column number to be added. The value may be positive, 
       
    35 zero or negative. */
       
    36 	{
       
    37 	iRow += aRowOffset;
       
    38 	iCol += aColOffset;
       
    39 	}
       
    40 
       
    41 EXPORT_C void TCellRef::InternalizeL(RReadStream& aStream)
       
    42 /** Internalises an object of this class from a read stream.
       
    43 
       
    44 The presence of this function means that the standard templated operator>>() 
       
    45 can be used to internalise objects of this class.
       
    46 
       
    47 Note that the function has assignment semantics. It replaces the old value 
       
    48 of the object with a new value read from the read stream. 
       
    49 
       
    50 @param aStream Stream from which the object is to be internalised. */
       
    51 	{
       
    52 	iRow = aStream.ReadInt32L();
       
    53 	iCol = aStream.ReadInt32L();
       
    54 	}
       
    55 
       
    56 // class TRangeRef
       
    57 
       
    58 EXPORT_C TBool TRangeRef::operator==(const TRangeRef& aRange) const
       
    59 /** Compares this cell range with the specified cell range for equality.
       
    60 
       
    61 @param aRange The cell range to be compared.
       
    62 @return ETrue, if the start cells and the end cells are the same. */
       
    63 	{
       
    64 	return aRange.iFrom==iFrom && aRange.iTo==iTo;
       
    65 	}
       
    66 
       
    67 EXPORT_C TInt TRangeRef::NoCells() const
       
    68 /** Gets the number of cells represented by the range.
       
    69 
       
    70 @return The number of cells. */
       
    71 	{
       
    72 	return NoRows()*NoCols();
       
    73 	}
       
    74 
       
    75 EXPORT_C TBool TRangeRef::Contains(const TCellRef& aCell) const
       
    76 /** Tests whether the specified cell is contained within the range.
       
    77 
       
    78 A range includes its outer perimeter.
       
    79 
       
    80 @param aCell The cell to be tested.
       
    81 @return ETrue, if the specified cell is contained within the range; 
       
    82 EFalse, otherwise. */
       
    83 	{
       
    84 	TInt row=aCell.iRow;
       
    85 	TInt col=aCell.iCol;
       
    86 	return row>=iFrom.iRow && row<=iTo.iRow && col>=iFrom.iCol && col<=iTo.iCol;
       
    87 	}
       
    88 
       
    89 EXPORT_C void TRangeRef::InternalizeL(RReadStream& aStream)
       
    90 /** Internalises an object of this class from a read stream.
       
    91 
       
    92 The presence of this function means that the standard templated operator>>() 
       
    93 can be used to internalise objects of this class.
       
    94 
       
    95 Note that the function has assignment semantics. It replaces the old value 
       
    96 of the object with a new value read from the read stream. 
       
    97 
       
    98 @param aStream Stream from which the object is to be internalised. */
       
    99 	{
       
   100 	aStream>>iFrom>>iTo;
       
   101 	}
       
   102 
       
   103 EXPORT_C void TRangeRef::ExternalizeL(RWriteStream& aStream) const
       
   104 /** Externalises an object of this class to a write stream.
       
   105 
       
   106 The presence of this function means that the standard templated operator<<() 
       
   107 can be used to externalise objects of this class. 
       
   108 
       
   109 @param aStream Stream to which the object should be externalised. */
       
   110 	{
       
   111 	aStream<<iFrom<<iTo; 
       
   112 	}
       
   113 
       
   114 // TRangeRef::TIter
       
   115 
       
   116 EXPORT_C TRangeRef::TIter::TIter(const TRangeRef& aRange)
       
   117 	: iCurrent(aRange.iFrom),iRange(aRange)
       
   118     {}
       
   119 
       
   120 EXPORT_C TBool TRangeRef::TIter::operator++()
       
   121 	{
       
   122 	if (iCurrent.iCol<iRange.iTo.iCol)
       
   123 		{
       
   124 		++iCurrent.iCol;
       
   125 		}
       
   126 	else
       
   127 		{
       
   128 		++iCurrent.iRow;
       
   129 		iCurrent.iCol = iRange.iFrom.iCol;
       
   130 		}
       
   131 	return iCurrent.iRow<=iRange.iFrom.iRow;
       
   132 	}
       
   133 
       
   134 
       
   135 /* End of $Workfile:   bacell.cpp  $*/