source: buchla-68k/orig/GP/ACCSKEL.C@ 6888aa2

Last change on this file since 6888aa2 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

  • Property mode set to 100755
File size: 9.1 KB
Line 
1/*
2 =============================================================================
3 accskel.c -- GEM desk accessory skelton
4 Version 1 -- 1988-08-10 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8/*
9 =============================================================================
10 Include files
11 =============================================================================
12*/
13
14#include "stddefs.h"
15#include "obdefs.h"
16#include "define.h"
17#include "gemdefs.h"
18#include "osbind.h"
19
20/*
21 =============================================================================
22 Defines
23 =============================================================================
24*/
25
26#define WI_KIND (SIZER | MOVER | FULLER | CLOSER | NAME)
27
28#define NO_WINDOW (-1)
29
30#define MIN_WIDTH (2 * gl_wbox)
31#define MIN_HEIGHT (3 * gl_hbox)
32
33/*
34
35*/
36
37/*
38 =============================================================================
39 Externals
40 =============================================================================
41*/
42
43extern int gl_apid;
44
45/*
46 =============================================================================
47 Global variables
48 =============================================================================
49*/
50
51int gl_hchar;
52int gl_wchar;
53int gl_wbox;
54int gl_hbox; /* system sizes */
55
56int menu_id ; /* our menu id */
57
58int phys_handle; /* physical workstation handle */
59int handle; /* virtual workstation handle */
60int wi_handle; /* window handle */
61int top_window; /* handle of topped window */
62
63int xdesk;
64int ydesk;
65int hdesk;
66int wdesk;
67
68int xold;
69int yold;
70int hold;
71int wold;
72
73int xwork;
74int ywork;
75int hwork;
76int wwork;
77
78int msgbuff[8]; /* event message buffer */
79int keycode; /* keycode returned by event-keyboard */
80int mx;
81int my; /* mouse x and y pos. */
82int butdown; /* button state tested for, UP/DOWN */
83int ret; /* dummy return variable */
84
85int hidden; /* current state of cursor */
86
87int fulled; /* current state of window */
88
89int contrl[12];
90int intin[128];
91int ptsin[128];
92int intout[128];
93int ptsout[128]; /* storage wasted for idiotic bindings */
94
95int work_in[11]; /* Input to GSX parameter array */
96int work_out[57]; /* Output from GSX parameter array */
97int pxyarray[10]; /* input point array */
98
99/*
100
101*/
102
103/*
104 =============================================================================
105 hide_mouse() -- hide mouse cursor
106 =============================================================================
107*/
108
109hide_mouse()
110{
111 if (! hidden) {
112
113 graf_mouse(M_OFF, 0x0L);
114 hidden = TRUE;
115 }
116}
117
118/*
119 =============================================================================
120 show_mouse() -- show mouse cursor
121 =============================================================================
122*/
123
124show_mouse()
125{
126 if (hidden) {
127
128 graf_mouse(M_ON, 0x0L);
129 hidden = FALSE;
130 }
131}
132
133/*
134
135*/
136
137/*
138 =============================================================================
139 open_vwork() -- open virtual workstation
140 =============================================================================
141*/
142
143open_vwork()
144{
145 int i;
146
147 for(i = 0; i < 10; work_in[i++] = 1);
148
149 work_in[10] = 2;
150 handle = phys_handle;
151 v_opnvwk(work_in, &handle, work_out);
152}
153
154/*
155
156*/
157
158/*
159 =============================================================================
160 set_clip() -- set clipping rectangle
161 =============================================================================
162*/
163
164set_clip(x, y, w, h)
165int x, y, w, h;
166{
167 int clip[4];
168
169 clip[0] = x;
170 clip[1] = y;
171 clip[2] = x + w;
172 clip[3] = y + h;
173
174 vs_clip(handle, 1, clip);
175}
176
177/*
178 =============================================================================
179 open_window() -- open a window
180 =============================================================================
181*/
182
183open_window()
184{
185 wi_handle = wind_create(WI_KIND, xdesk, ydesk, wdesk, hdesk);
186
187 wind_set(wi_handle, WF_NAME, " IMA SAMPLE ", 0, 0);
188
189 graf_growbox(xdesk + wdesk / 2, ydesk + hdesk / 2,
190 gl_wbox, gl_hbox, xdesk, ydesk, wdesk, hdesk);
191
192 wind_open(wi_handle, xdesk, ydesk, wdesk, hdesk);
193 wind_get(wi_handle, WF_WORKXYWH, &xwork, &ywork, &wwork, &hwork);
194}
195
196/*
197
198*/
199
200/*
201 =============================================================================
202 do_redraw() -- find and redraw all clipping rectangles
203 =============================================================================
204*/
205
206do_redraw(xc, yc, wc, hc)
207int xc, yc, wc, hc;
208{
209 GRECT t1,t2;
210
211 hide_mouse();
212 wind_update(TRUE);
213
214 t2.g_x = xc;
215 t2.g_y = yc;
216 t2.g_w = wc;
217 t2.g_h = hc;
218
219 wind_get(wi_handle,WF_FIRSTXYWH,&t1.g_x,&t1.g_y,&t1.g_w,&t1.g_h);
220
221 while (t1.g_w AND t1.g_h) {
222
223 if (rc_intersect(&t2, &t1)) {
224
225 set_clip(t1.g_x, t1.g_y, t1.g_w, t1.g_h);
226 draw_sample();
227 }
228
229 wind_get(wi_handle ,WF_NEXTXYWH,
230 &t1.g_x, &t1.g_y, &t1.g_w, &t1.g_h);
231 }
232
233 wind_update(FALSE);
234 show_mouse();
235}
236
237/*
238
239*/
240
241/*
242 =============================================================================
243 main() -- Accessory initialization
244 =============================================================================
245*/
246
247main()
248{
249 appl_init();
250
251 phys_handle = graf_handle(&gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox);
252
253 menu_id = menu_register(gl_apid, " Sample Accessory");
254
255 wind_get(0, WF_WORKXYWH, &xdesk, &ydesk, &wdesk, &hdesk);
256
257 wi_handle = NO_WINDOW;
258
259 hidden = FALSE;
260 fulled = FALSE;
261 butdown = TRUE;
262
263 multi();
264}
265
266/*
267
268*/
269
270/*
271 =============================================================================
272 multi() -- dispatch accessory tasks
273 =============================================================================
274*/
275
276multi()
277{
278 int event;
279
280 while (TRUE) {
281
282 event = evnt_multi(MU_MESAG | MU_BUTTON | MU_KEYBD,
283 1, 1, butdown,
284 0, 0, 0, 0, 0,
285 0, 0, 0, 0, 0,
286 msgbuff, 0, 0, &mx, &my,
287 &ret, &ret, &keycode, &ret);
288
289 wind_update(TRUE);
290
291 wind_get(wi_handle, WF_TOP, &top_window, &ret, &ret, &ret);
292
293 if (event & MU_MESAG)
294 switch (msgbuff[0]) {
295
296 case WM_REDRAW:
297
298 if (msgbuff[3] EQ wi_handle)
299 do_redraw(msgbuff[4], msgbuff[5],
300 msgbuff[6], msgbuff[7]);
301
302 break;
303
304 case WM_NEWTOP:
305 case WM_TOPPED:
306
307 if (msgbuff[3] EQ wi_handle) {
308
309 wind_set(wi_handle,WF_TOP,0,0,0,0);
310 }
311
312 break;
313/*
314
315*/
316 case AC_CLOSE:
317
318 if((msgbuff[3] EQ menu_id) AND (wi_handle NE NO_WINDOW)) {
319
320 v_clsvwk(handle);
321 wi_handle = NO_WINDOW;
322 }
323
324 break;
325
326 case WM_CLOSED:
327
328 if(msgbuff[3] EQ wi_handle){
329
330 wind_close(wi_handle);
331
332 graf_shrinkbox(xwork + wwork / 2,
333 ywork + hwork / 2,
334 gl_wbox, gl_hbox,
335 xwork, ywork,
336 wwork, hwork);
337
338 wind_delete(wi_handle);
339 v_clsvwk(handle);
340 wi_handle = NO_WINDOW;
341 }
342
343 break;
344/*
345
346*/
347 case WM_SIZED:
348 case WM_MOVED:
349
350 if(msgbuff[3] EQ wi_handle) {
351
352 if(msgbuff[6] < MIN_WIDTH)
353 msgbuff[6] = MIN_WIDTH;
354
355 if(msgbuff[7] < MIN_HEIGHT)
356 msgbuff[7] = MIN_HEIGHT;
357
358 wind_set(wi_handle ,WF_CURRXYWH,
359 msgbuff[4], msgbuff[5],
360 msgbuff[6], msgbuff[7]);
361
362 wind_get(wi_handle, WF_WORKXYWH,
363 &xwork, &ywork,
364 &wwork, &hwork);
365 }
366
367 break;
368/*
369
370*/
371 case AC_OPEN:
372
373 if (msgbuff[4] EQ menu_id) {
374
375 if(wi_handle EQ NO_WINDOW) {
376
377 open_vwork();
378 open_window();
379
380 } else {
381
382 /* if already opened, for user convenience */
383
384 wind_set(wi_handle,WF_TOP,0,0,0,0);
385 }
386 }
387
388 break;
389/*
390
391*/
392 case WM_FULLED:
393
394 if(fulled) {
395
396 wind_calc(WC_WORK, WI_KIND,
397 xold, yold, wold, hold,
398 &xwork, &ywork, &wwork, &hwork);
399
400 wind_set(wi_handle, WF_CURRXYWH,
401 xold, yold, wold, hold);
402
403 } else {
404
405 wind_calc(WC_BORDER, WI_KIND,
406 xwork, ywork, wwork, hwork,
407 &xold, &yold, &wold, &hold);
408
409 wind_calc(WC_WORK, WI_KIND,
410 xdesk, ydesk, wdesk, hdesk,
411 &xwork, &ywork, &wwork, &hwork);
412
413 wind_set(wi_handle, WF_CURRXYWH,
414 xdesk, ydesk, wdesk, hdesk);
415 }
416
417 fulled ^= TRUE;
418 break;
419
420 } /* end of switch (msgbuff[0]) */
421/*
422
423*/
424 if ((event & MU_BUTTON) AND (wi_handle EQ top_window))
425 if(butdown)
426 butdown = FALSE;
427 else
428 butdown = TRUE;
429
430 if (event & MU_KEYBD) {
431
432 do_redraw(xwork, ywork, wwork, hwork);
433 }
434
435 wind_update(FALSE);
436
437 } /* end of while (TRUE) */
438}
439
440/*
441
442*/
443
444/*
445 =============================================================================
446 draw_sample() -- SAMPLE: Draw Filled Ellipse
447 =============================================================================
448*/
449
450draw_sample()
451{
452 int temp[4];
453
454 vsf_interior(handle, 2);
455 vsf_style(handle, 8);
456 vsf_color(handle, 0);
457
458 temp[0] = xwork;
459 temp[1] = ywork;
460 temp[2] = xwork + wwork - 1;
461 temp[3] = ywork + hwork - 1;
462
463 v_bar(handle, temp); /* blank the interior */
464 vsf_interior(handle, 4);
465 vsf_color(handle, 1);
466
467 v_ellipse(handle, xwork + wwork / 2, ywork + hwork / 2,
468 wwork / 2, hwork / 2);
469}
Note: See TracBrowser for help on using the repository browser.