comparison anagram/support/cint.h @ 0:13d2b8934445

Import AnaGram (near-)release tree into Mercurial.
author David A. Holland
date Sat, 22 Dec 2007 17:52:45 -0500
parents
children 607e3be6bad8
comparison
equal deleted inserted replaced
-1:000000000000 0:13d2b8934445
1 /*
2 * AnaGram, A System for Syntax Directed Programming
3 * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
4 * See the file COPYING for license and usage terms.
5 *
6 * cint.h
7 */
8
9 #ifndef CINT_H
10 #define CINT_H
11
12 #ifdef VACLGUI
13 #include <ipoint.hpp>
14 #endif
15
16 struct rect;
17
18
19 struct cint {
20 int x, y;
21
22 cint()
23 : x(0), y(0)
24 {}
25 cint(const int xarg, const int yarg)
26 : x(xarg), y(yarg)
27 {}
28 cint(const cint &c)
29 : x(c.x), y(c.y)
30 {}
31
32 #ifdef VACLGUI
33 cint(const IPair &p)
34 : x(p.coord1()), y(p.coord2())
35 {}
36 operator IPair () const {
37 return IPair(x, y);
38 }
39 #endif
40
41 int operator == (const cint r) const { return (x == r.x && y == r.y); }
42 int operator != (const cint r) const { return (x != r.x || y != r.y); }
43 cint operator + (cint r) const {
44 r.x += x;
45 r.y += y;
46 return r;
47 }
48 cint operator += (const cint r) {
49 x += r.x;
50 y += r.y;
51 return *this;
52 }
53 cint operator - (cint r) const {
54 r.x = x - r.x;
55 r.y = y - r.y;
56 return r;
57 }
58 cint operator -= (const cint r) {
59 x -= r.x;
60 y -= r.y;
61 return *this;
62 }
63 int operator <= (const cint &s) const;
64 int operator >= (const cint &s) const;
65 int operator < (const cint &s) const;
66 int operator > (const cint &s) const;
67 int on_boundary(cint, cint) const;
68 int inside_rect(cint, cint) const;
69 int inside_rect(rect) const;
70 };
71
72 struct rect {
73 cint pos, size;
74 };
75
76 cint lrci(cint a, cint b);
77 int measure_line(const char *s);
78 cint measure_string(const char *s);
79 cint place(cint measure, cint size, int jm);
80 rect place_rect(rect w, cint s, int jm);
81 cint ulci(cint a, cint b);
82
83
84 #endif /* CINT_H */