First checkin, AXE release 0.2
[AXE.git] / src / shape.h
1 /*
2  *  C++ X Windows class library
3  */
4
5 #include <X11/Xlib.h>
6
7 class point
8 {
9    short  _x, _y;
10
11 public:
12
13    point()   { _x = 0; _y = 0; }
14
15    point(int x, int y)   { _x = x; _y = y; }
16
17    short x()   { return _x; }
18
19    short y()   { return _y; }
20
21 };
22
23
24 class line
25 {
26    int   npoints;
27    int   mode;
28    point *points;
29
30
31    void drawline(drawable &d);
32
33 public:
34
35    line()
36    {
37       npoints = 0;
38       mode = CoordModeOrigin;
39    }
40
41    line(short x1, short y1, short x2, short y2)
42    {
43       npoints = 2;
44       mode = CoordModeOrigin;
45       points = new point[2];
46       points[0] = point(x1, y1);
47       points[1] = point(x2, y2);
48    }
49
50    line(point p1, point p2)
51    {
52       npoints = 2;
53       mode = CoordModeOrigin;
54       points = new point[2];
55       points[0] = p1;
56       points[1] = p2;
57    }
58
59    ~line()
60    {
61       if (npoints != 0)
62          delete [] points;
63    }
64
65    point &operator[] (int index);
66
67 };
68
69 class rectangle
70 {
71    short          x, y;
72    unsigned short width, height;
73
74
75 public:
76
77    rectangle()
78    {
79       x      = 0;
80       y      = 0;
81       width  = 0;
82       height = 0;
83    }
84
85    rectangle(int _x, int _y, unsigned int _w, unsigned int _h)
86    {
87       x      = _x;
88       y      = _y;
89       width  = _w;
90       height = _h;
91    }
92
93    //  Define a rectangle by its diagonal
94
95    rectangle(point p1, point p2);
96
97 };
98
99 class box
100 {
101    short          x, y;
102    unsigned short width, height;
103
104 public:
105
106    box()
107    {
108       x      = 0;
109       y      = 0;
110       width  = 0;
111       height = 0;
112    }
113
114    box(int _x, int _y, unsigned int _w, unsigned int _h)
115    {
116       x      = _x;
117       y      = _y;
118       width  = _w;
119       height = _h;
120    }
121
122    //  Define a box by its diagonal
123
124    box(point p1, point p2);
125
126 };
127
128 class text
129 {
130    short x, y;
131    String txt;
132
133
134 public:
135
136    text()
137    {
138       x = 0;
139       y = 0;
140    }
141
142    text(int _x, int _y, String str)
143    {
144       x = _x;
145       y = _y;
146       txt = str;
147    }
148
149    text(point p, String s)
150    {
151       x = p.x();
152       y = p.y();
153       txt = s;
154    }
155
156 };