-
Notifications
You must be signed in to change notification settings - Fork 34
/
wxGraphics.h
190 lines (131 loc) · 5.3 KB
/
wxGraphics.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/* pen_info is a stucture type with fields for the various
pen characteristics including the location, size, color,
mode (e.g. XOR or COPY), pattern, visibility (0 = visible) */
typedef struct {
int color;
int xpos;
int ypos;
int vis;
int pw;
int ph;
int pen_md;
} pen_info;
struct mypoint {
int x,y;
};
pen_info* getPen();
extern void wxPrepare();
extern void wxSetPenWidth(int width);
extern void wxDrawLine(int x1, int y1, int x2, int y2, int vis);
extern void wx_clear();
extern void wxLabel(char * string);
extern void wxTextScreen();
extern void wxSplitScreen();
extern void wxFullScreen();
extern void wxSetInfo(int type, int val);
extern int wxGetMouseX();
extern int wxGetMouseY();
extern int wxGetClickX();
extern int wxGetClickY();
extern int wxGetButton();
extern int wxGetLastButton();
extern void doFilled(int fillcolor, int count, struct mypoint *points);
#define SCREEN_WIDTH 1
#define SCREEN_HEIGHT 2
#define BACK_GROUND 3
#define IN_SPLITSCREEN 4
#define IN_GRAPHICS_MODE 5
#define NUMCOLORS 256
#define NUMINITCOLORS 16
#define GR_SIZE 60000
#define prepare_to_draw wxPrepare()
#define done_drawing nop()
#define prepare_to_draw_turtle nop()
#define done_drawing_turtle nop()
//#define screen_height (1 + screen_bottom - screen_top)
//#define screen_width (1 + screen_right - screen_left)
#define screen_width wxGetInfo(SCREEN_WIDTH)
#define screen_height wxGetInfo(SCREEN_HEIGHT)
#define back_ground wxGetInfo(BACK_GROUND)
#define xgr_pen getPen()
#define screen_left 0
#define screen_right (screen_width)
#define screen_top 0
#define screen_bottom (screen_height)
#define screen_x_center (screen_left + (screen_width)/2)
#define screen_y_center (screen_top + (screen_height)/2)
#define turtle_left_max ((screen_left) - (screen_x_center))
#define turtle_right_max ((screen_right) - (screen_x_center))
#define turtle_top_max ((screen_y_center) - (screen_top))
#define turtle_bottom_max ((screen_y_center) - (screen_bottom))
#define screen_x_coord ((screen_x_center) + turtle_x)
#define screen_y_coord ((screen_y_center) - turtle_y)
#define turtle_height 18
#define turtle_half_bottom 6.0
#define turtle_side 19.0
#define refresh_screen() wx_refresh();
#define clear_screen wx_clear();
#define erase_screen() wx_clear();
#define line_to(a,b) wxDrawLine(xgr_pen->xpos, \
xgr_pen->ypos,a,b,!xgr_pen->vis);\
xgr_pen->xpos=(a);\
xgr_pen->ypos=(b)
#define move_to(a,b) xgr_pen->xpos=(a); \
xgr_pen->ypos=(b); \
turtlePosition_x=screen_x_coord; \
turtlePosition_y=screen_y_coord;
#define draw_string(s) wxLabel(s);
#define set_pen_vis(v) xgr_pen->vis=(v)
#define set_pen_mode(m) xgr_pen->pen_md=(m)
#define set_pen_color(c) draw_turtle();\
xgr_pen->color=c%NUMCOLORS;\
draw_turtle();
#define set_back_ground(c) wxSetInfo(BACK_GROUND,c%NUMCOLORS);\
redraw_graphics();
#define set_pen_width(w) wxSetPenWidth(w);
#define set_pen_height(h) nop();
#define set_pen_x(x) nop()
#define set_pen_y(y) nop()
#define p_info_x(p) (p.xpos)
#define p_info_y(p) (p.ypos)
/* All these should take an argument, like the two just above.
Then we could support multiple turtles.
*/
#define pen_width xgr_pen->pw
#define pen_height xgr_pen->pw /* not ph, which isn't set */
#define pen_color xgr_pen->color
#define pen_mode xgr_pen->pen_md
#define pen_vis xgr_pen->vis
#define pen_x (xgr_pen->xpos)
#define pen_y (xgr_pen->ypos)
#define get_node_pen_pattern (cons(make_intnode(-1), NIL))
#define PEN_REVERSE 0
#define PEN_ERASE 1
#define PEN_DOWN 2
#define pen_reverse pen_mode=PEN_REVERSE
#define pen_erase pen_mode=PEN_ERASE
#define pen_down pen_mode=PEN_DOWN
#define button wxGetButton()
#define lastbutton wxGetLastButton()
#define mouse_x wxGetMouseX()
#define mouse_y wxGetMouseY()
#define click_x wxGetClickX()
#define click_y wxGetClickY()
#define full_screen wxFullScreen()
#define split_screen wxSplitScreen()
#define text_screen wxTextScreen()
#define in_splitscreen wxGetInfo(IN_SPLITSCREEN)
#define in_graphics_mode wxGetInfo(IN_GRAPHICS_MODE)
#define plain_xor_pen() pen_reverse
#define label(s) wxLabel(s)
#define tone(p,d) nop()
#define get_pen_pattern(p) nop()
#define set_pen_pattern(p) nop()
#define set_list_pen_pattern(p) nop()
extern void set_palette(int, unsigned int, unsigned int, unsigned int);
extern void get_palette(int, unsigned int*, unsigned int*, unsigned int*);
extern void save_pen(pen_info*), restore_pen(pen_info*);
extern void logofill();
/* The sparc has fmod. So I use it. */
/* #define fmod(x,y) x */
extern void nop();