Mercurial > ~dholland > hg > ag > index.cgi
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/anagram/support/cint.h Sat Dec 22 17:52:45 2007 -0500 @@ -0,0 +1,84 @@ +/* + * AnaGram, A System for Syntax Directed Programming + * Copyright 1993-2002 Parsifal Software. All Rights Reserved. + * See the file COPYING for license and usage terms. + * + * cint.h + */ + +#ifndef CINT_H +#define CINT_H + +#ifdef VACLGUI +#include <ipoint.hpp> +#endif + +struct rect; + + +struct cint { + int x, y; + + cint() + : x(0), y(0) + {} + cint(const int xarg, const int yarg) + : x(xarg), y(yarg) + {} + cint(const cint &c) + : x(c.x), y(c.y) + {} + +#ifdef VACLGUI + cint(const IPair &p) + : x(p.coord1()), y(p.coord2()) + {} + operator IPair () const { + return IPair(x, y); + } +#endif + + int operator == (const cint r) const { return (x == r.x && y == r.y); } + int operator != (const cint r) const { return (x != r.x || y != r.y); } + cint operator + (cint r) const { + r.x += x; + r.y += y; + return r; + } + cint operator += (const cint r) { + x += r.x; + y += r.y; + return *this; + } + cint operator - (cint r) const { + r.x = x - r.x; + r.y = y - r.y; + return r; + } + cint operator -= (const cint r) { + x -= r.x; + y -= r.y; + return *this; + } + int operator <= (const cint &s) const; + int operator >= (const cint &s) const; + int operator < (const cint &s) const; + int operator > (const cint &s) const; + int on_boundary(cint, cint) const; + int inside_rect(cint, cint) const; + int inside_rect(rect) const; +}; + +struct rect { + cint pos, size; +}; + +cint lrci(cint a, cint b); +int measure_line(const char *s); +cint measure_string(const char *s); +cint place(cint measure, cint size, int jm); +rect place_rect(rect w, cint s, int jm); +cint ulci(cint a, cint b); + + +#endif /* CINT_H */