summaryrefslogtreecommitdiff
path: root/basegfx/inc/basegfx/range/basicrange.hxx
diff options
context:
space:
mode:
authorArmin Weiss <aw@openoffice.org>2004-01-16 13:30:10 +0000
committerArmin Weiss <aw@openoffice.org>2004-01-16 13:30:10 +0000
commit99a300e39ace4f9bd1af8ad85ef49f35f7117fc7 (patch)
tree9ef5e2b8c9359e42cd27ca82d6614249a9474314 /basegfx/inc/basegfx/range/basicrange.hxx
parentc794c5ce7ea7b11f7275a471821310dcd3dd552e (diff)
Added == and != operators to ranges, some other goodies, too. Also changed remaining sal_Bool to bool. Renamed B(2|3)(d|i)box to ...volume.
Diffstat (limited to 'basegfx/inc/basegfx/range/basicrange.hxx')
-rw-r--r--basegfx/inc/basegfx/range/basicrange.hxx36
1 files changed, 33 insertions, 3 deletions
diff --git a/basegfx/inc/basegfx/range/basicrange.hxx b/basegfx/inc/basegfx/range/basicrange.hxx
index 120e930c4523..3a8aab0ab51c 100644
--- a/basegfx/inc/basegfx/range/basicrange.hxx
+++ b/basegfx/inc/basegfx/range/basicrange.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: basicrange.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: thb $ $Date: 2004-01-16 10:34:10 $
+ * last change: $Author: aw $ $Date: 2004-01-16 14:30:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -132,6 +132,16 @@ namespace basegfx
return !((rRange.mnMinimum < mnMinimum) || (rRange.mnMaximum > mnMaximum));
}
+ bool operator==( const BasicRange& rRange ) const
+ {
+ return (mnMinimum == rRange.mnMinimum && mnMaximum == rRange.mnMaximum);
+ }
+
+ bool operator!=( const BasicRange& rRange ) const
+ {
+ return (mnMinimum != rRange.mnMinimum || mnMaximum != rRange.mnMaximum);
+ }
+
void operator=(const BasicRange& rRange)
{
mnMinimum = rRange.mnMinimum;
@@ -164,11 +174,31 @@ namespace basegfx
}
}
+ void grow(T nValue)
+ {
+ bool bLessThanZero(nValue < 0);
+
+ if(nValue > 0 || bLessThanZero)
+ {
+ mnMinimum -= nValue;
+ mnMaximum += nValue;
+
+ if(bLessThanZero)
+ {
+ // test if range did collapse
+ if(mnMinimum > mnMaximum)
+ {
+ // if yes, collapse to center
+ mnMinimum = mnMaximum = (mnMinimum + mnMaximum) / 2.0;
+ }
+ }
+ }
+ }
+
typename Traits::DifferenceType getRange() const
{
return (mnMaximum - mnMinimum);
}
-
};
// some pre-fabricated traits