-
Notifications
You must be signed in to change notification settings - Fork 1
/
DrawRut.c
223 lines (192 loc) · 5.3 KB
/
DrawRut.c
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#include "xvt.h"
#include "noddy.h"
#include "nodInc.h"
#include <math.h>
#include "scales.h"
#define DEBUG(X)
/* ************************* */
/* Globals used in this file */
static WINDOW currentDrawingWindow = (WINDOW) 0;
static int ixcur = 0, iycur = 0;
static int pointSizeX = 1, pointSizeY = 1;
void setCurrentDrawingWindow (win)
WINDOW win;
{
DRAW_CTOOLS tools;
currentDrawingWindow = win;
if (win)
{
xvt_app_get_default_ctools (&tools);
tools.pen.pat = PAT_SOLID;
tools.brush.pat = PAT_SOLID;
xvt_dwin_set_draw_ctools(currentDrawingWindow, &tools);
}
}
WINDOW getCurrentDrawingWindow ()
{
return (currentDrawingWindow);
}
/* ************************************************************************
** set the clip rectangle for the window
************************************************************************ */
void
#if XVT_CC_PROTO
setClipRect (RCT *clipRect, BOOLEAN clipOn)
#else
setClipRect (clipRect, clipOn)
RCT *clipRect;
BOOLEAN clipOn;
#endif
{
if (clipOn)
xvt_dwin_set_clip (currentDrawingWindow, clipRect);
else
xvt_dwin_set_clip (currentDrawingWindow, (RCT *) NULL);
}
/* ************************************************************************
** set the size of points drawn with DrawPoint
************************************************************************ */
void
#if XVT_CC_PROTO
SetColor (COLOR color)
#else
SetColor (color)
COLOR color;
#endif
{
DRAW_CTOOLS tools;
xvt_dwin_get_draw_ctools(currentDrawingWindow, &tools);
tools.pen.color = color;
tools.brush.color = color;
xvt_dwin_set_draw_ctools(currentDrawingWindow, &tools);
}
/* ************************************************************************
** set the size of points drawn with DrawPoint
************************************************************************ */
void
#if XVT_CC_PROTO
SetPointSize (int size)
#else
SetPointSize (size)
int size;
#endif
{
pointSizeX = size;
pointSizeY = size;
}
/* ************************************************************************
** set the size of points drawn with DrawPoint
************************************************************************ */
void
#if XVT_CC_PROTO
SetRectPointSize (int sizeX, int sizeY)
#else
SetRectPointSize (sizeX, sizeY)
int sizeX, sizeY;
#endif
{
pointSizeX = sizeX;
pointSizeY = sizeY;
}
/* ************************************************************************
** place the pen a position ix, iy
************************************************************************ */
void
#if XVT_CC_PROTO
DrawPoint (int ix, int iy)
#else
DrawPoint (ix,iy)
int ix, iy;
#endif
{
RCT point;
point.bottom = iy;
point.top = point.bottom - pointSizeY;
point.left = ix;
point.right = point.left + pointSizeX;
xvt_dwin_draw_rect (currentDrawingWindow, &point);
ixcur = ix; iycur = iy;
}
/* ************************************************************************
** place the pen a position ix, iy
************************************************************************ */
void
#if XVT_CC_PROTO
moveTo (int ix, int iy)
#else
moveTo (ix,iy)
int ix,iy;
#endif
{
PNT point;
point.h = ix;
point.v = iy;
xvt_dwin_draw_set_pos (currentDrawingWindow, point);
ixcur = ix; iycur = iy;
}
/* ************************************************************************
** draw a line from the current pen position to ix, iy, leaving the
** pen at position ix, iy
************************************************************************ */
void lineTo(ix,iy)
int ix,iy;
{
PNT point;
point.h = ix;
point.v = iy;
xvt_dwin_draw_line (currentDrawingWindow, point);
xvt_dwin_draw_set_pos (currentDrawingWindow, point);
ixcur = ix; iycur = iy;
}
/*
Function that draw a point at a location.
It is used to make lines actually draw on the start Point and the end point
*/
int pointAt(ix,iy)
int ix,iy;
{
#if (XVTWS == WIN16WS) || (XVTWS == WIN32WS)
PNT point;
point.h = ix;
point.v = iy;
xvt_dwin_draw_set_pos (currentDrawingWindow, point);
point.h = ix-1;
xvt_dwin_draw_line (currentDrawingWindow, point);
ixcur = ix; iycur = iy;
#endif
return (TRUE);
}
/* ************************************************************************
** draw a line from the current pen position to a relative position of
** currentPositionX + ix and currentPositionY + iy
************************************************************************ */
void line(ix,iy)
int ix,iy;
{
PNT point;
point.h = ixcur + ix;
point.v = iycur + iy;
xvt_dwin_draw_line (currentDrawingWindow, point);
xvt_dwin_draw_set_pos (currentDrawingWindow, point);
ixcur += ix; iycur += iy;
}
/* ************************************************************************
** write a string at the current pen position
************************************************************************ */
void drawString(ix, iy, temp)
int ix, iy;
char *temp;
{
xvt_dwin_draw_text (currentDrawingWindow, ix, iy, temp, -1);
}
/* ************************************************************************
************************************************************************ */
void penSize(iw,ih)
int iw,ih;
{
DRAW_CTOOLS tools;
xvt_app_get_default_ctools(&tools);
tools.pen.width = iw;
tools.pen.pat = PAT_SOLID;
xvt_dwin_set_draw_ctools(currentDrawingWindow, &tools);
}