summaryrefslogtreecommitdiff
path: root/include/basegfx/tuple/b2ituple.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'include/basegfx/tuple/b2ituple.hxx')
-rw-r--r--include/basegfx/tuple/b2ituple.hxx119
1 files changed, 7 insertions, 112 deletions
diff --git a/include/basegfx/tuple/b2ituple.hxx b/include/basegfx/tuple/b2ituple.hxx
index b8f6c3e96386..e3f195596a37 100644
--- a/include/basegfx/tuple/b2ituple.hxx
+++ b/include/basegfx/tuple/b2ituple.hxx
@@ -21,6 +21,7 @@
#include <sal/types.h>
#include <basegfx/basegfxdllapi.h>
+#include <basegfx/tuple/Tuple2D.hxx>
namespace basegfx
{
@@ -32,143 +33,37 @@ namespace basegfx
@derive Use this class to implement Points or Vectors
which are based on two sal_Int32 values
*/
- class SAL_WARN_UNUSED BASEGFX_DLLPUBLIC B2ITuple
+ class SAL_WARN_UNUSED BASEGFX_DLLPUBLIC B2ITuple : public Tuple2D<sal_Int32>
{
- protected:
- sal_Int32 mnX;
- sal_Int32 mnY;
-
public:
/** Create a 2D Tuple
The tuple is initialized to (0, 0)
*/
B2ITuple()
- : mnX(0),
- mnY(0)
+ : Tuple2D(0, 0)
{}
/** Create a 2D Tuple
- @param fX
+ @param nX
This parameter is used to initialize the X-coordinate
of the 2D Tuple.
- @param fY
+ @param nY
This parameter is used to initialize the Y-coordinate
of the 2D Tuple.
*/
- B2ITuple(sal_Int32 fX, sal_Int32 fY)
- : mnX( fX ),
- mnY( fY )
+ B2ITuple(sal_Int32 nX, sal_Int32 nY)
+ : Tuple2D(nX, nY)
{}
- /// Get X-Coordinate of 2D Tuple
- sal_Int32 getX() const
- {
- return mnX;
- }
-
- /// Get Y-Coordinate of 2D Tuple
- sal_Int32 getY() const
- {
- return mnY;
- }
-
- /// Set X-Coordinate of 2D Tuple
- void setX(sal_Int32 fX)
- {
- mnX = fX;
- }
-
- /// Set Y-Coordinate of 2D Tuple
- void setY(sal_Int32 fY)
- {
- mnY = fY;
- }
-
- /// Array-access to 2D Tuple
- const sal_Int32& operator[] (int nPos) const
- {
- // Here, normally one if(...) should be used. In the assumption that
- // both sal_Int32 members can be accessed as an array a shortcut is used here.
- // if(0 == nPos) return mnX; return mnY;
- return *((&mnX) + nPos);
- }
-
- /// Array-access to 2D Tuple
- sal_Int32& operator[] (int nPos)
- {
- // Here, normally one if(...) should be used. In the assumption that
- // both sal_Int32 members can be accessed as an array a shortcut is used here.
- // if(0 == nPos) return mnX; return mnY;
- return *((&mnX) + nPos);
- }
-
// operators
-
- B2ITuple& operator+=( const B2ITuple& rTup )
- {
- mnX += rTup.mnX;
- mnY += rTup.mnY;
- return *this;
- }
-
- B2ITuple& operator-=( const B2ITuple& rTup )
- {
- mnX -= rTup.mnX;
- mnY -= rTup.mnY;
- return *this;
- }
-
- B2ITuple& operator/=( const B2ITuple& rTup )
- {
- mnX /= rTup.mnX;
- mnY /= rTup.mnY;
- return *this;
- }
-
- B2ITuple& operator*=( const B2ITuple& rTup )
- {
- mnX *= rTup.mnX;
- mnY *= rTup.mnY;
- return *this;
- }
-
- B2ITuple& operator*=(sal_Int32 t)
- {
- mnX *= t;
- mnY *= t;
- return *this;
- }
-
- B2ITuple& operator/=(sal_Int32 t)
- {
- mnX /= t;
- mnY /= t;
- return *this;
- }
-
B2ITuple operator-(void) const
{
return B2ITuple(-mnX, -mnY);
}
-
- bool equalZero() const
- {
- return mnX == 0 && mnY == 0;
- }
-
- bool operator==( const B2ITuple& rTup ) const
- {
- return this == &rTup || (rTup.mnX == mnX && rTup.mnY == mnY);
- }
-
- bool operator!=( const B2ITuple& rTup ) const
- {
- return !(*this == rTup);
- }
};
// external operators