1 /*
2 ** Copyright (C) 1993-2013 Mark B. Hanson (mbh@panix.com)
3 **
4 ** This program is free software; you can redistribute it and/or modify
5 ** it under the terms of the GNU General Public License as published by
6 ** the Free Software Foundation; either version 2, or (at your option)
7 ** any later version.
8 **
9 ** This program is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ** GNU General Public License for more details.
13 **
14 ** You should have received a copy of the GNU General Public License
15 ** along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 // @(#)$Id: thing.h 1344 2013-04-05 21:18:39Z mark $
19 
20 #ifdef	XSC_THING_H
21 
22 class Thing;
23 
24 #else	// XSC_THING_H
25 #define	XSC_THING_H
26 
27 class Thing {
28 protected:
29     float x;
30     float y;
31     float size;
32     float scale;
33     float diag;
34 
35     Window window;
36     GC gc;
37 
38     int num_points;
39     const struct coords *points;
40     XPoint *xpoints;
41 
42 public:
43     Thing(void);
44     virtual ~Thing(void);
45 
46     float get_size(void) const;
47     void set_size(const float);
48 
49     float get_scale(void) const;
50     void set_scale(const float);
51 
52     Window get_window(void) const;
53     void set_window(const Window);
54 
55     GC get_gc(void) const;
56     void set_gc(const GC);
57 
58     float get_x(void) const;
59     void set_x(float);
60 
61     float get_y(void) const;
62     void set_y(float);
63 
64     float get_diag(void) const;
65 
66     virtual void set_points(const struct coords *, const int);
67 
68     virtual XPoint *get_xpoints(void) const;
69     virtual void set_xpoints(void);
70 
71     virtual void paint_points(const bool) const;
72 
73     virtual void render(const bool);
74     void draw(void);
75     void erase(void);
76 
77     virtual void resize(const int, const int);
78 };
79 
80 
81 inline float
get_size(void)82 Thing::get_size(void) const
83 {
84     return size;
85 } // Thing::get_size
86 
87 
88 inline float
get_scale(void)89 Thing::get_scale(void) const
90 {
91     return scale;
92 } // Thing::get_scale
93 
94 
95 inline Window
get_window(void)96 Thing::get_window(void) const
97 {
98     return window;
99 } // Thing::get_window
100 
101 
102 inline void
set_window(const Window w)103 Thing::set_window(const Window w)
104 {
105     window = w;
106 } // Thing::set_window
107 
108 
109 inline GC
get_gc(void)110 Thing::get_gc(void) const
111 {
112     return gc;
113 } // Thing::get_gc
114 
115 
116 inline void
set_gc(const GC ngc)117 Thing::set_gc(const GC ngc)
118 {
119     gc = ngc;
120 } // Thing::set_gc
121 
122 
123 inline float
get_x(void)124 Thing::get_x(void) const
125 {
126     return x;
127 } // Thing::get_x
128 
129 
130 inline void
set_x(float nx)131 Thing::set_x(float nx)
132 {
133     x = nx;
134 } // Thing::set_x
135 
136 
137 inline float
get_y(void)138 Thing::get_y(void) const
139 {
140     return y;
141 } // Thing::get_y
142 
143 
144 inline void
set_y(float ny)145 Thing::set_y(float ny)
146 {
147     y = ny;
148 } // Thing::set_y
149 
150 
151 inline float
get_diag(void)152 Thing::get_diag(void) const
153 {
154     return diag;
155 } // Thing::get_diag
156 
157 
158 inline void
draw(void)159 Thing::draw(void)
160 {
161     render(true);
162 } // Thing::draw
163 
164 
165 inline void
erase(void)166 Thing::erase(void)
167 {
168     render(false);
169 } // Thing::erase
170 
171 #endif	// XSC_THING_H
172