Beispiel #1
0
bool CRectangle::Contains(const CRectangle& rc) const
{
    int left1, top1, right1, bottom1;
    int left2, top2, right2, bottom2;
    left1 = GetX();
    top1 = GetY();
    right1 = GetX() + GetW();
    bottom1 = GetY() + GetH();

    left2 = rc.GetX();
    top2 = rc.GetY();
    right2 = rc.GetX() + rc.GetW();
    bottom2 = rc.GetY() + rc.GetH();

//    return !(left1 < right2 && right1 > left2 &&
//        top1 > bottom2 && bottom1 < top2);
//    return (left1 < right2 || right1 > left2 ||
//        top1 > bottom2 || bottom1 < top2);
//    return ((left1 < right2) || (right1 > left2) ||
//        (top1 > bottom2) || (bottom1 < top2));
//    return (!(left1 < right2) || !(right1 > left2) ||
//        !(top1 > bottom2) || !(bottom1 < top2));
//    return (!(left1 < right2) && !(right1 > left2) &&
//        !(top1 > bottom2) && !(bottom1 < top2));

    bool xOverlap = valueInRange(left1, left2, right2) ||
        valueInRange(left2, left1, right1);

    bool yOverlap = valueInRange(top1, top2, bottom2) ||
        valueInRange(top2, top1, bottom1);

    return xOverlap && yOverlap;

}
Beispiel #2
0
CRectangle CRectangle::Pad(const CRectangle& rc) const {
    CRectangle result(*this);
    result.X() += rc.GetX();
    result.Y() += rc.GetY();
    result.W() -= rc.GetW() + rc.GetX();
    result.H() -= rc.GetH() + rc.GetY();
    return result;
}
Beispiel #3
0
CRectangle CRectangle::operator - (CRectangle& rc) const {
    int left1, top1, right1, bottom1;
    int left2, top2, right2, bottom2;

    CRectangle result;
    result.SetEmpty();

    left1 = GetX();
    top1 = GetY();
    right1 = GetX() + GetW();
    bottom1 = GetY() + GetH();

    left2 = rc.GetX();
    top2 = rc.GetY();
    right2 = rc.GetX() + rc.GetW();
    bottom2 = rc.GetY() + rc.GetH();

    if(left1 < left2) { left1 = left2; }

    if(top1 < top2) { top1 = top2; }

    if(right1 > right2) { right1 = right2; }

    if(bottom1 > bottom2) { bottom1 = bottom2; }

    right1 -= left1;
    bottom1 -= top1;

    if(right1 > 0 && bottom1 > 0) {
        result.X() = left1;
        result.Y() = top1;
        result.W() = right1;
        result.H() = bottom1;
    }

    return (result);
} // -
Beispiel #4
0
CRectangle::CRectangle (const CRectangle& rc) {
//: pimpl_(new CRectangle::CRectangleImpl)
    Set(rc.GetX(), rc.GetY(), rc.GetW(), rc.GetH());
    //( *this ) = rc ;
}
Beispiel #5
0
bool CRectangle::operator == (CRectangle& rc) const {
    return (GetX() == rc.GetX() && GetY() == rc.GetY() && GetW() == rc.GetW() && GetH() == rc.GetH());
}