7 #define MIN(a,b) ((a) < (b) ? (a) : (b))
11 #define MAX(a,b) ((a) > (b) ? (a) : (b))
18 eSize( int w
, int h
);
26 void setWidth( int w
);
27 void setHeight( int h
);
30 eSize
expandedTo( const eSize
& ) const;
31 eSize
boundedTo( const eSize
& ) const;
36 eSize
&operator+=( const eSize
& );
37 eSize
&operator-=( const eSize
& );
38 eSize
&operator*=( int c
);
39 eSize
&operator*=( double c
);
40 eSize
&operator/=( int c
);
41 eSize
&operator/=( double c
);
43 friend inline bool operator==( const eSize
&, const eSize
& );
44 friend inline bool operator!=( const eSize
&, const eSize
& );
45 friend inline eSize
operator+( const eSize
&, const eSize
& );
46 friend inline eSize
operator-( const eSize
&, const eSize
& );
47 friend inline eSize
operator*( const eSize
&, int );
48 friend inline eSize
operator*( int, const eSize
& );
49 friend inline eSize
operator*( const eSize
&, double );
50 friend inline eSize
operator*( double, const eSize
& );
51 friend inline eSize
operator/( const eSize
&, int );
52 friend inline eSize
operator/( const eSize
&, double );
60 /*****************************************************************************
61 eSize stream functions
62 *****************************************************************************/
66 inline ostream
&operator<<( ostream
&s
, const eSize
&sz
)
68 s
<< sz
.width() << sz
.height();
72 inline istream
&operator>>( istream
&s
, eSize
&sz
)
74 s
>> sz
.rwidth() >> sz
.rheight();
80 /*****************************************************************************
81 eSize inline functions
82 *****************************************************************************/
87 inline eSize::eSize( int w
, int h
)
90 inline bool eSize::isNull() const
91 { return wd
==0 && ht
==0; }
93 inline bool eSize::isEmpty() const
94 { return wd
<1 || ht
<1; }
96 inline bool eSize::isValid() const
97 { return wd
>=0 && ht
>=0; }
99 inline int eSize::width() const
102 inline int eSize::height() const
105 inline void eSize::setWidth( int w
)
108 inline void eSize::setHeight( int h
)
111 inline int &eSize::rwidth()
114 inline int &eSize::rheight()
117 inline eSize
&eSize::operator+=( const eSize
&s
)
118 { wd
+=s
.wd
; ht
+=s
.ht
; return *this; }
120 inline eSize
&eSize::operator-=( const eSize
&s
)
121 { wd
-=s
.wd
; ht
-=s
.ht
; return *this; }
123 inline eSize
&eSize::operator*=( int c
)
124 { wd
*=c
; ht
*=c
; return *this; }
126 inline eSize
&eSize::operator*=( double c
)
127 { wd
=(int)(wd
*c
); ht
=(int)(ht
*c
); return *this; }
129 inline bool operator==( const eSize
&s1
, const eSize
&s2
)
130 { return s1
.wd
== s2
.wd
&& s1
.ht
== s2
.ht
; }
132 inline bool operator!=( const eSize
&s1
, const eSize
&s2
)
133 { return s1
.wd
!= s2
.wd
|| s1
.ht
!= s2
.ht
; }
135 inline eSize
operator+( const eSize
& s1
, const eSize
& s2
)
136 { return eSize(s1
.wd
+s2
.wd
, s1
.ht
+s2
.ht
); }
138 inline eSize
operator-( const eSize
&s1
, const eSize
&s2
)
139 { return eSize(s1
.wd
-s2
.wd
, s1
.ht
-s2
.ht
); }
141 inline eSize
operator*( const eSize
&s
, int c
)
142 { return eSize(s
.wd
*c
, s
.ht
*c
); }
144 inline eSize
operator*( int c
, const eSize
&s
)
145 { return eSize(s
.wd
*c
, s
.ht
*c
); }
147 inline eSize
operator*( const eSize
&s
, double c
)
148 { return eSize((int)(s
.wd
*c
), (int)(s
.ht
*c
)); }
150 inline eSize
operator*( double c
, const eSize
&s
)
151 { return eSize((int)(s
.wd
*c
), (int)(s
.ht
*c
)); }
153 inline eSize
&eSize::operator/=( int c
)
159 inline eSize
&eSize::operator/=( double c
)
161 wd
=(int)(wd
/c
); ht
=(int)(ht
/c
);
165 inline eSize
operator/( const eSize
&s
, int c
)
167 return eSize(s
.wd
/c
, s
.ht
/c
);
170 inline eSize
operator/( const eSize
&s
, double c
)
172 return eSize((int)(s
.wd
/c
), (int)(s
.ht
/c
));
175 inline eSize
eSize::expandedTo( const eSize
& otherSize
) const
177 return eSize( MAX(wd
,otherSize
.wd
), MAX(ht
,otherSize
.ht
) );
180 inline eSize
eSize::boundedTo( const eSize
& otherSize
) const
182 return eSize( MIN(wd
,otherSize
.wd
), MIN(ht
,otherSize
.ht
) );
185 inline void eSize::transpose()