4 /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
5 Written by James Clark (jjc@jclark.com)
7 This file is part of groff.
9 groff is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2, or (at your option) any later
14 groff is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 You should have received a copy of the GNU General Public License along
20 with groff; see the file COPYING. If not, write to the Free Software
21 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
31 vunits
& operator+=(const vunits
&);
32 vunits
& operator-=(const vunits
&);
33 friend inline vunits
scale(vunits n
, units x
, units y
); // scale n by x/y
34 friend inline vunits
scale(vunits n
, vunits x
, vunits y
);
35 friend inline vunits
operator +(const vunits
&, const vunits
&);
36 friend inline vunits
operator -(const vunits
&, const vunits
&);
37 friend inline vunits
operator -(const vunits
&);
38 friend inline int operator /(const vunits
&, const vunits
&);
39 friend inline vunits
operator /(const vunits
&, int);
40 friend inline vunits
operator *(const vunits
&, int);
41 friend inline vunits
operator *(int, const vunits
&);
42 friend inline int operator <(const vunits
&, const vunits
&);
43 friend inline int operator >(const vunits
&, const vunits
&);
44 friend inline int operator <=(const vunits
&, const vunits
&);
45 friend inline int operator >=(const vunits
&, const vunits
&);
46 friend inline int operator ==(const vunits
&, const vunits
&);
47 friend inline int operator !=(const vunits
&, const vunits
&);
60 hunits
& operator+=(const hunits
&);
61 hunits
& operator-=(const hunits
&);
62 friend inline hunits
scale(hunits n
, units x
, units y
); // scale n by x/y
63 friend inline hunits
scale(hunits n
, double x
);
64 friend inline hunits
operator +(const hunits
&, const hunits
&);
65 friend inline hunits
operator -(const hunits
&, const hunits
&);
66 friend inline hunits
operator -(const hunits
&);
67 friend inline int operator /(const hunits
&, const hunits
&);
68 friend inline hunits
operator /(const hunits
&, int);
69 friend inline hunits
operator *(const hunits
&, int);
70 friend inline hunits
operator *(int, const hunits
&);
71 friend inline int operator <(const hunits
&, const hunits
&);
72 friend inline int operator >(const hunits
&, const hunits
&);
73 friend inline int operator <=(const hunits
&, const hunits
&);
74 friend inline int operator >=(const hunits
&, const hunits
&);
75 friend inline int operator ==(const hunits
&, const hunits
&);
76 friend inline int operator !=(const hunits
&, const hunits
&);
81 extern int get_vunits(vunits
*, unsigned char si
);
82 extern int get_hunits(hunits
*, unsigned char si
);
83 extern int get_vunits(vunits
*, unsigned char si
, vunits prev_value
);
84 extern int get_hunits(hunits
*, unsigned char si
, hunits prev_value
);
86 inline vunits:: vunits() : n(0)
90 inline units
vunits::to_units()
95 inline int vunits::is_zero()
100 inline vunits
operator +(const vunits
& x
, const vunits
& y
)
108 inline vunits
operator -(const vunits
& x
, const vunits
& y
)
116 inline vunits
operator -(const vunits
& x
)
123 inline int operator /(const vunits
& x
, const vunits
& y
)
128 inline vunits
operator /(const vunits
& x
, int n
)
136 inline vunits
operator *(const vunits
& x
, int n
)
144 inline vunits
operator *(int n
, const vunits
& x
)
152 inline int operator <(const vunits
& x
, const vunits
& y
)
157 inline int operator >(const vunits
& x
, const vunits
& y
)
162 inline int operator <=(const vunits
& x
, const vunits
& y
)
167 inline int operator >=(const vunits
& x
, const vunits
& y
)
172 inline int operator ==(const vunits
& x
, const vunits
& y
)
177 inline int operator !=(const vunits
& x
, const vunits
& y
)
183 inline vunits
& vunits::operator+=(const vunits
& x
)
189 inline vunits
& vunits::operator-=(const vunits
& x
)
195 inline hunits:: hunits() : n(0)
199 inline units
hunits::to_units()
201 return n
*hresolution
;
204 inline int hunits::is_zero()
209 inline hunits
operator +(const hunits
& x
, const hunits
& y
)
217 inline hunits
operator -(const hunits
& x
, const hunits
& y
)
225 inline hunits
operator -(const hunits
& x
)
233 inline int operator /(const hunits
& x
, const hunits
& y
)
238 inline hunits
operator /(const hunits
& x
, int n
)
246 inline hunits
operator *(const hunits
& x
, int n
)
254 inline hunits
operator *(int n
, const hunits
& x
)
262 inline int operator <(const hunits
& x
, const hunits
& y
)
267 inline int operator >(const hunits
& x
, const hunits
& y
)
272 inline int operator <=(const hunits
& x
, const hunits
& y
)
277 inline int operator >=(const hunits
& x
, const hunits
& y
)
282 inline int operator ==(const hunits
& x
, const hunits
& y
)
287 inline int operator !=(const hunits
& x
, const hunits
& y
)
293 inline hunits
& hunits::operator+=(const hunits
& x
)
299 inline hunits
& hunits::operator-=(const hunits
& x
)
305 inline hunits
scale(hunits n
, units x
, units y
)
308 r
.n
= scale(n
.n
, x
, y
);
312 inline vunits
scale(vunits n
, units x
, units y
)
315 r
.n
= scale(n
.n
, x
, y
);
319 inline vunits
scale(vunits n
, vunits x
, vunits y
)
322 r
.n
= scale(n
.n
, x
.n
, y
.n
);
326 inline hunits
scale(hunits n
, double x
)
333 inline units
scale(units n
, double x
)
338 inline units
points_to_units(units n
)
340 return scale(n
, units_per_inch
, 72);