34 friend std::ostream & operator<<( std::ostream & STREAM,
const wpair & OBJ );
43 wpair(
const int v = 0 ) { A = B = v; }
45 wpair(
const int a,
const int b ) { A = a; B = b; }
47 wpair(
const wpair & Rhs ) { A = Rhs.A; B = Rhs.B; }
53 wpair & operator= (
const wpair & Rhs ) { A = Rhs.A; B = Rhs.B;
return *
this; }
55 wpair & operator+=(
const wpair & Rhs ) { A += Rhs.A; B += Rhs.B;
return *
this; }
57 wpair & operator-=(
const wpair & Rhs ) { A -= Rhs.A; B -= Rhs.B;
return *
this; }
59 wpair & operator*=(
const wpair & Rhs ) { A *= Rhs.A; B *= Rhs.B;
return *
this; }
61 wpair & operator/=(
const wpair & Rhs ) { A /= Rhs.A; B /= Rhs.B;
return *
this; }
63 wpair operator+(
const wpair & Rhs )
const {
return wpair( A + Rhs.A, B + Rhs.B ); }
65 wpair operator-(
const wpair & Rhs )
const {
return wpair( A - Rhs.A, B - Rhs.B ); }
67 wpair operator*(
const wpair & Rhs )
const {
return wpair( A * Rhs.A, B * Rhs.B ); }
69 wpair operator/(
const wpair & Rhs )
const {
return wpair( A / Rhs.A, B / Rhs.B ); }
73 bool operator==(
const wpair & Rhs )
const {
return A == Rhs.A && B == Rhs.B; }
75 bool operator!=(
const wpair & Rhs )
const {
return A != Rhs.A || B != Rhs.B; }
77 bool operator> (
const wpair & Rhs )
const {
return A > Rhs.A && B > Rhs.B; }
79 bool operator< (
const wpair & Rhs )
const {
return A < Rhs.A && B < Rhs.B; }
81 bool operator>=(
const wpair & Rhs )
const {
return A >= Rhs.A && B >= Rhs.B; }
83 bool operator<=(
const wpair & Rhs )
const {
return A <= Rhs.A && B <= Rhs.B; }
88 return min( max( *
this, Min ), Max );
93 return wpair( Lhs.A < Rhs.A ? Lhs.A : Rhs.A,
94 Lhs.B < Rhs.B ? Lhs.B : Rhs.B );
99 return wpair( Lhs.A > Rhs.A ? Lhs.A : Rhs.A,
100 Lhs.B > Rhs.B ? Lhs.B : Rhs.B );
117 wpos(
const int v = 0 ) :
wpair( v ), L( A ), C( B ) {}
119 wpos(
const int l,
const int c ) :
wpair( l, c ), L( A ), C( B ) {}
129 wpos & operator= (
const wpos & Rhs ) { wpair::operator= ( Rhs );
return *
this; }
131 wpos & operator+=(
const wpair & Rhs ) { wpair::operator+=( Rhs );
return *
this; }
133 wpos & operator-=(
const wpair & Rhs ) { wpair::operator-=( Rhs );
return *
this; }
135 wpos & operator*=(
const wpair & Rhs ) { wpair::operator*=( Rhs );
return *
this; }
137 wpos & operator/=(
const wpair & Rhs ) { wpair::operator/=( Rhs );
return *
this; }
139 wpos operator+(
const wpair & Rhs )
const {
return wpair::operator+( Rhs ); }
141 wpos operator-(
const wpair & Rhs )
const {
return wpair::operator-( Rhs ); }
143 wpos operator*(
const wpair & Rhs )
const {
return wpair::operator*( Rhs ); }
145 wpos operator/(
const wpair & Rhs )
const {
return wpair::operator/( Rhs ); }
148 extern std::ostream & operator<<( std::ostream & STREAM,
const wpos & OBJ );
162 wsze(
const int v = 0 ) :
wpair( v ), H( A ), W( B ) {}
164 wsze(
const int h,
const int w ) :
wpair( h, w ), H( A ), W( B ) {}
172 wsze & operator= (
const wsze & Rhs ) { wpair::operator= ( Rhs );
return *
this; }
174 wsze & operator+=(
const wpair & Rhs ) { wpair::operator+=( Rhs );
return *
this; }
176 wsze & operator-=(
const wpair & Rhs ) { wpair::operator-=( Rhs );
return *
this; }
178 wsze & operator*=(
const wpair & Rhs ) { wpair::operator*=( Rhs );
return *
this; }
180 wsze & operator/=(
const wpair & Rhs ) { wpair::operator/=( Rhs );
return *
this; }
182 wsze operator+(
const wpair & Rhs )
const {
return wpair::operator+( Rhs ); }
184 wsze operator-(
const wpair & Rhs )
const {
return wpair::operator-( Rhs ); }
186 wsze operator*(
const wpair & Rhs )
const {
return wpair::operator*( Rhs ); }
188 wsze operator/(
const wpair & Rhs )
const {
return wpair::operator/( Rhs ); }
191 extern std::ostream & operator<<( std::ostream & STREAM,
const wsze & OBJ );
205 wrect() : Pos( 0 ), Sze( 0 ) {}
207 wrect(
const wpos & pos,
const wsze & sze ) : Pos( pos ), Sze( sze ) {}
213 bool operator==(
const wrect & Rhs )
const
215 return Pos == Rhs.Pos && Sze == Rhs.Sze;
218 bool operator!=(
const wrect & Rhs )
const {
return !operator==( Rhs ); }
227 incpos.L = decsze.H = 0;
230 incpos.C = decsze.W = 0;
232 return wrect( Pos + incpos, Sze - decsze );
236 wrect intersectRelTo(
const wrect & par )
const
239 if ( !( Pos < par.Sze ) )
246 ret.Sze.H = par.Sze.H - ret.Pos.L;
249 ret.Sze.W = par.Sze.W - ret.Pos.C;
251 if ( !( ret.Pos + ret.Sze >= 0 ) )
259 ret.Sze.H += ret.Pos.L;
265 ret.Sze.W += ret.Pos.C;
270 ret.Sze = wpair::min( ret.Sze, par.Sze - ret.Pos );
277 extern std::ostream & operator<<( std::ostream & STREAM,
const wrect & OBJ );