1 | /*
|
---|
2 | =============================================================================
|
---|
3 | egaes.c -- An example GEM application program in C
|
---|
4 | Version 2 -- 1989-01-24 -- Metacomco / Lattice
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include "portab.h"
|
---|
9 |
|
---|
10 | /* a very useful macro */
|
---|
11 |
|
---|
12 | #define ADDR(a) ((long)a)>>16,((long)a)&0xffff
|
---|
13 |
|
---|
14 | char wind_name[] = "Example";
|
---|
15 |
|
---|
16 | main()
|
---|
17 | {
|
---|
18 | WORD work_in[12], work_out[57];
|
---|
19 | WORD handle, i, j, k, l,xstart,ystart,xwidth,ywidth,xcen,ycen;
|
---|
20 | WORD gr_1,gr_2,gr_3,gr_4;
|
---|
21 | WORD wi_1,wi_2,wi_3,wi_4;
|
---|
22 | WORD w_handle;
|
---|
23 | WORD clip[4];
|
---|
24 | WORD mgbuf[8];
|
---|
25 | WORD wind_type;
|
---|
26 | WORD dflag,xt;
|
---|
27 |
|
---|
28 | /* Set the system up to do GEM calls*/
|
---|
29 |
|
---|
30 | appl_init();
|
---|
31 |
|
---|
32 | /* Get the handle of the desktop */
|
---|
33 |
|
---|
34 | handle=graf_handle(&gr_1,&gr_2,&gr_3,&gr_4);
|
---|
35 |
|
---|
36 | /* Open the workstation. */
|
---|
37 |
|
---|
38 | for(i=0; i<10; i++)
|
---|
39 | work_in[i] = 1;
|
---|
40 | work_in[10] = 2;
|
---|
41 |
|
---|
42 | v_opnvwk(work_in, &handle, work_out);
|
---|
43 |
|
---|
44 | graf_mouse(0,1);
|
---|
45 | wind_type=0x002b;
|
---|
46 |
|
---|
47 | /* |
---|
48 |
|
---|
49 | */
|
---|
50 |
|
---|
51 | /* request size of desktop window */
|
---|
52 |
|
---|
53 | wind_get(0,4,&wi_1,&wi_2,&wi_3,&wi_4);
|
---|
54 |
|
---|
55 | /* calculate size of work area */
|
---|
56 |
|
---|
57 | wind_calc(1,wind_type,wi_1,wi_2,wi_3,wi_4,&i,&j,&k,&l);
|
---|
58 |
|
---|
59 | /* make window of the max size */
|
---|
60 |
|
---|
61 | w_handle=wind_create(wind_type,wi_1,wi_2,wi_3,wi_4);
|
---|
62 | wind_set(w_handle,2,ADDR( wind_name ),0,0);
|
---|
63 | wind_open(w_handle,wi_1,wi_2,wi_3,wi_4);
|
---|
64 | xstart=i;
|
---|
65 | ystart=j;
|
---|
66 | xwidth=k;
|
---|
67 | ywidth=l;
|
---|
68 |
|
---|
69 | do {
|
---|
70 |
|
---|
71 | if (mgbuf[0]!=20) { /* ignore redraw */
|
---|
72 |
|
---|
73 | v_hide_c(handle);
|
---|
74 | clip[0]=xstart; clip[1]=ystart;
|
---|
75 | clip[2]=xstart+xwidth-1; clip[3]=ystart+ywidth-1;
|
---|
76 | vs_clip(handle,1,clip);
|
---|
77 | xcen=xstart+xwidth/2;
|
---|
78 | ycen=ystart+ywidth/2;
|
---|
79 | vsf_interior(handle,2);
|
---|
80 | vsf_style(handle,8);
|
---|
81 | vsf_color(handle,0);
|
---|
82 | v_bar(handle,clip);
|
---|
83 | vsf_interior(handle,4);
|
---|
84 | vsf_color(handle,1);
|
---|
85 | v_ellipse(handle,xcen,ycen,xwidth/2,ywidth/2);
|
---|
86 | v_show_c(handle);
|
---|
87 | }
|
---|
88 |
|
---|
89 | evnt_mesag(&mgbuf);
|
---|
90 | /* |
---|
91 |
|
---|
92 | */
|
---|
93 | if( mgbuf[0]==28 || mgbuf[0]==27 ) {
|
---|
94 |
|
---|
95 | wind_calc(1,wind_type,mgbuf[4],mgbuf[5],
|
---|
96 | mgbuf[6],mgbuf[7],&xstart,&ystart,
|
---|
97 | &xwidth,&ywidth);
|
---|
98 |
|
---|
99 | if ((xt=xwidth)<gr_3) {
|
---|
100 |
|
---|
101 | xwidth=gr_3;
|
---|
102 | mgbuf[6]+=gr_3-xt;
|
---|
103 | }
|
---|
104 |
|
---|
105 | if((xt=ywidth)<gr_4) {
|
---|
106 |
|
---|
107 | ywidth=gr_4;
|
---|
108 | mgbuf[7]+=gr_4-xt;
|
---|
109 | }
|
---|
110 |
|
---|
111 | dflag=0;
|
---|
112 |
|
---|
113 | wind_set(w_handle,5,
|
---|
114 | mgbuf[4],mgbuf[5],
|
---|
115 | mgbuf[6],mgbuf[7]);
|
---|
116 | }
|
---|
117 |
|
---|
118 | } while(mgbuf[0]!=22);
|
---|
119 |
|
---|
120 | /* Close the workstation. */
|
---|
121 |
|
---|
122 | wind_close(w_handle);
|
---|
123 | wind_delete(w_handle);
|
---|
124 | v_clsvwk(handle);
|
---|
125 |
|
---|
126 | /* Release GEM application */
|
---|
127 |
|
---|
128 | appl_exit();
|
---|
129 |
|
---|
130 | /* and quit */
|
---|
131 |
|
---|
132 | _exit(0);
|
---|
133 | }
|
---|
134 |
|
---|