# dont perform the libgen and libsocket test in configure for AROS.
[AROS-Contrib.git] / fish / surf / gadgetdef.c
bloba1bb9ee7e143646be6f307c580412a78de47f569
1 /* this file contains definition for the screen */
3 #include <aros/oldprograms.h>
4 #include "scrnio.ih"
5 #include <exec/memory.h>
6 #ifdef MANX
7 #include <functions.h>
8 #endif
10 #include "scrndef.h"
11 #include "gadgetdef.h"
12 #include "mytypes.h"
13 #include "bezpt.h"
14 #include "poly.h"
15 #include "revolve.h"
16 #include "readilbm.h"
18 void OutErr(char *);
19 void CloseDisplay();
20 void GadgetSetVal(struct Gadget *);
21 void GadgetUpdate(struct Gadget *, bool);
24 * definition for image of hourglass
26 static UWORD HourGlassDat[] = {
27 0x0, 0x0, 0x0, 0xffff,
28 0x7ffe, 0x8001, 0x6006, 0x9ff9,
29 0x2004, 0x5ffa, 0x1c38, 0x2ff4,
30 0xf70, 0x17e8, 0x7e0, 0xbd0,
31 0x2c0, 0x5a0, 0x240, 0x5a0,
32 0x420, 0xbd0, 0x910, 0x17e8,
33 0x1788, 0x2ff4, 0x2fe4, 0x5ffa,
34 0x7ff6, 0x9ff9, 0x7ffe, 0x8001,
35 0x0, 0xffff, 0x0, 0x0
38 UWORD *HourGlass = NULL;
44 * actual gadget definitions
46 #define TOP 13
47 #define ROW 9
48 #define COL 8
49 #define TxOff 1
51 * start of boolean gadgets
53 #define BOOLGADFLAGS (RELVERIFY|TOPBORDER)
54 #define BOOLTOP 0
55 #define BOOLLEFT 0
57 static struct IntuiText TextDefLines = {
58 -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Lines", NULL };
60 static struct Gadget G_DefLines = {
61 NULL,
62 BOOLLEFT , BOOLTOP , 5*COL, ROW, /* loc and size of hit box */
63 GADGHBOX, /* complemented when pressed */
64 BOOLGADFLAGS, /* just get gadget up messages */
65 BOOLGADGET,
66 NULL, NULL,
67 &TextDefLines,
68 0, NULL,
69 (int)N_DefLines,
70 NULL
74 static struct IntuiText TextEditBez = {
75 -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Curves", NULL };
77 static struct Gadget G_EditBez = {
78 &G_DefLines,
79 BOOLLEFT+COL*6, BOOLTOP, 6*COL, ROW, /* loc and size of hit box */
80 GADGHBOX, /* complemented when pressed */
81 RELVERIFY, /* just get gadget up messages */
82 BOOLGADGET,
83 NULL, NULL,
84 &TextEditBez,
85 0, NULL,
86 (int)N_EditBez,
87 NULL
91 static struct IntuiText TextMap = {
92 -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Map", NULL };
94 static struct Gadget G_Map = {
95 &G_EditBez,
96 BOOLLEFT +24*COL, BOOLTOP, 3*COL, ROW, /* loc and size of hit box */
97 GADGHBOX, /* complemented when pressed */
98 RELVERIFY, /* just get gadget up messages */
99 BOOLGADGET,
100 NULL, NULL,
101 &TextMap,
102 0, NULL,
103 (int)N_Map,
104 NULL
108 static struct IntuiText TextWire = {
109 -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Wire", NULL };
111 static struct Gadget G_Wire = {
112 &G_Map,
113 BOOLLEFT +13*COL, BOOLTOP, 4*COL, ROW, /* loc and size of hit box */
114 GADGHBOX, /* complemented when pressed */
115 RELVERIFY, /* just get gadget up messages */
116 BOOLGADGET,
117 NULL, NULL,
118 &TextWire,
119 0, NULL,
120 (int)N_Wire,
121 NULL
124 static struct IntuiText TextShaded = {
125 -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Shade", NULL };
127 static struct Gadget G_Shaded = {
128 &G_Wire,
129 BOOLLEFT +18*COL, BOOLTOP, 5*COL, ROW, /* loc and size of hit box */
130 GADGHBOX, /* complemented when pressed */
131 RELVERIFY, /* just get gadget up messages */
132 BOOLGADGET,
133 NULL, NULL,
134 &TextShaded,
135 0, NULL,
136 (int)N_Shaded,
137 NULL
140 static struct IntuiText TextGoPanel = {
141 -1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Panel", NULL };
143 static struct Gadget G_GoPanel = {
144 &G_Shaded,
145 BOOLLEFT +28*COL, BOOLTOP, 5*COL, ROW, /* loc and size of hit box */
146 GADGHBOX, /* complemented when pressed */
147 RELVERIFY, /* just get gadget up messages */
148 BOOLGADGET,
149 NULL, NULL,
150 &TextGoPanel,
151 0, NULL,
152 (int)N_GoPanel,
153 NULL
156 static struct IntuiText TextGoSurf = {
157 1,-1,JAM1, 0, TxOff, NULL,(UBYTE *) "Display", NULL };
159 static short S_GoSurf[] = {
160 -2,-1, -2,ROW+1, 7*COL+2,ROW+1, 7*COL+2,-1, -2,-1
163 static struct Border B_GoSurf = { 0, 0, 1, 0, JAM1, 5, S_GoSurf, NULL };
165 static struct Gadget G_GoSurf = {
166 NULL,
167 2*COL, TOP, 7*COL, ROW, /* loc and size of hit box */
168 GADGHBOX, /* complemented when pressed */
169 RELVERIFY, /* just get gadget up messages */
170 BOOLGADGET,
171 (APTR)&B_GoSurf, NULL,
172 &TextGoSurf,
173 0, NULL,
174 (int)N_GoSurf,
175 NULL
179 * beginning of slider gadgets
181 #define GadFlags (GADGIMAGE | GADGHNONE) /* my gadget flags */
182 #define MyPropType (PROPGADGET)
185 * definitions for the number of Revolution Slices
188 static char DispRevSlices[] = "Rev Slices=[ ]";
190 static struct IntuiText TextRevSlices = {
191 1,1,JAM1, -16*COL, TxOff, NULL,
192 (UBYTE *)DispRevSlices, NULL
195 struct GadExtens VRevSlices = {0.0, 0.0, 0.0, 1, 360, DefRevMeshVal, false };
197 static struct Gadget G_RevSlices = {
198 &G_GoSurf,
199 COL*57 , TOP+ROW*2, COL*15, ROW, /* loc and size */
200 GadFlags,
201 RELVERIFY,
202 MyPropType,
203 NULL,
204 NULL , /* high lighted */
205 &TextRevSlices,
206 0x0,
207 NULL,
208 (int)N_RevSlices,
209 (APTR) &VRevSlices
213 * definition for the background shade
215 static char DispBackPlane[] = { "Background = [ ]" };
217 static struct IntuiText TextBackPlane = {
218 1,1,JAM1, -17*COL, TxOff, NULL,
219 (UBYTE *)DispBackPlane, NULL
222 struct GadExtens VBackPlane = {0.0, 0.0, 0.0, 0, 31, DefBkPlane, false};
225 static struct Gadget G_BackPlane = {
226 &G_RevSlices,
227 COL*57 , TOP+ROW*13, COL*15, ROW, /* loc and size */
228 GadFlags,
229 RELVERIFY,
230 MyPropType,
231 NULL,
232 NULL , /* high lighted */
233 &TextBackPlane,
234 0x0,
235 NULL,
236 (int)N_BackPlane,
237 (APTR) &VBackPlane
242 * definitions for the number of Revolution Angles
245 static char DispRevAngle[] = { "Rev Angle=[ ]" };
247 static struct IntuiText TextRevAngle = {
248 1,1,JAM1, -15*COL, TxOff, NULL,
249 (UBYTE *)DispRevAngle, NULL
252 struct GadExtens VRevAngle = { 0.0, 0.0, 0.0, 0, 360, DefRotRange, false };
255 static struct Gadget G_RevAngle = {
256 &G_BackPlane,
257 COL*57 , TOP+ROW*3, COL*15, ROW, /* loc and size */
258 GadFlags,
259 RELVERIFY,
260 MyPropType ,
261 NULL,
262 NULL, /* high lighted */
263 &TextRevAngle,
264 0x0,
265 NULL,
266 (int)N_RevAngle,
267 (APTR) &VRevAngle
270 * definitions for start rotation angle
273 static char DispRevStart[] = { "Start Angle=[ ]" };
275 static struct IntuiText TextRevStart = {
276 1,1,JAM1, -17*COL, TxOff, NULL,
277 (UBYTE *)DispRevStart, NULL
280 struct GadExtens VRevStart = { 0.0, 0.0, 0.0, 0, 360, DefRotStart, false };
283 static struct Gadget G_RevStart = {
284 &G_RevAngle,
285 COL*57 , TOP+ROW*4, COL*15, ROW, /* loc and size */
286 GadFlags,
287 RELVERIFY,
288 MyPropType ,
289 NULL,
290 NULL, /* high lighted */
291 &TextRevStart,
292 0x0,
293 NULL,
294 (int)N_RevStart,
295 (APTR) &VRevStart
299 * definitions for the number of Bezier Slices
302 static char DispBezSlices[] = { "Bez Slices=[ ]" };
304 static struct IntuiText TextBezSlices = {
305 1,1,JAM1, -16*COL, TxOff, NULL,
306 (UBYTE *)DispBezSlices, NULL
310 struct GadExtens VBezSlices = { 0.0, 0.0, 0.0, 1, 100, DefBezMeshVal, false };
312 static struct Gadget G_BezSlices = {
313 &G_RevStart,
314 COL*20 , TOP+ROW*2, COL*15, ROW, /* loc and size */
315 GadFlags,
316 RELVERIFY,
317 MyPropType ,
318 NULL,
319 NULL, /* high lighted */
320 &TextBezSlices,
321 0x0,
322 NULL,
323 (int)N_BezSlices,
324 (APTR)&VBezSlices
328 * definitions for tilt angle
331 static char DispTiltAng[] = { "Tilt Angle=[ ]" };
333 static struct IntuiText TextTiltAng = {
334 1,1,JAM1, -16*COL, TxOff, NULL,
335 (UBYTE *)DispTiltAng, NULL
339 struct GadExtens VTiltAng = { 0.0, 0.0, 0.0, 0, 360, DefTilt, false };
341 static struct Gadget G_TiltAng = {
342 &G_BezSlices,
343 COL*20 , TOP+ROW*3, COL*15, ROW, /* loc and size */
344 GadFlags,
345 RELVERIFY,
346 MyPropType ,
347 NULL,
348 NULL, /* high lighted */
349 &TextTiltAng,
350 0x0,
351 NULL,
352 (int)N_TiltAng,
353 (APTR) &VTiltAng
358 * definitions for K Specular
361 static char DispKspec[] = {"Kspecular=[ ] " };
363 static struct IntuiText TextKspec = {
364 1,1,JAM1, (WORD)-sizeof(DispKspec)*COL, TxOff, NULL,
365 (UBYTE *)DispKspec, NULL
369 struct GadExtens VKspec = { 0.0, 1.0, DefKs, 0, 0, 0, true };
371 static struct Gadget G_Kspec = {
372 &G_TiltAng,
373 49*COL , TOP+ROW*9, COL*15, ROW, /* loc and size */
374 GadFlags,
375 RELVERIFY,
376 MyPropType ,
377 NULL,
378 NULL, /* high lighted */
379 &TextKspec,
380 0x0,
381 NULL,
382 (int)N_Kspec,
383 (APTR) &VKspec
387 * definitions for K diffuse
390 static char DispKdiffuse[] = {"Kdiffuse=[ ] " };
392 static struct IntuiText TextKdiffuse = {
393 1,1,JAM1, (WORD)-sizeof(DispKdiffuse)*COL, TxOff, NULL,
394 (UBYTE *)DispKdiffuse, NULL
398 struct GadExtens VKdiffuse = { 0.0, 1.0, DefKd, 0, 0, 0, true };
400 static struct Gadget G_Kdiffuse = {
401 &G_Kspec,
402 49*COL , TOP+ROW*10, COL*15, ROW, /* loc and size */
403 GadFlags,
404 RELVERIFY,
405 MyPropType ,
406 NULL,
407 NULL, /* high lighted */
408 &TextKdiffuse,
409 0x0,
410 NULL,
411 (int)N_Kdiffuse,
412 (APTR) &VKdiffuse
418 * definitions for DispPtIntens
422 static struct IntuiText PtProperties = {
423 1,1,JAM1, -10*COL, -ROW, NULL,
424 (UBYTE *)"Properties", NULL
427 static char DispPtIntens[] = {"Intensity=[ ] " };
429 static struct IntuiText TextPtIntens = {
430 1,1,JAM1, (WORD)-sizeof(DispPtIntens)*COL, TxOff, NULL,
431 (UBYTE *)DispPtIntens, &PtProperties
435 struct GadExtens VPtIntens = { 0.0, 2.5, DefIntensity , 0, 0, 0, true };
437 static struct Gadget G_PtIntens = {
438 &G_Kdiffuse,
439 49*COL , TOP+ROW*8, COL*15, ROW, /* loc and size */
440 GadFlags,
441 RELVERIFY,
442 MyPropType ,
443 NULL,
444 NULL, /* high lighted */
445 &TextPtIntens,
446 0x0,
447 NULL,
448 (int)N_PtIntens,
449 (APTR) &VPtIntens
456 * definitions for background intensity
458 static struct IntuiText DispAmbient= {
459 1,1,JAM1,- COL*3, -ROW, NULL,
460 (UBYTE *) "Other", NULL
463 static char DispBkIntens[] = { "Ambience=[ ] " };
465 static struct IntuiText TextBkIntens = {
466 1,1,JAM1, (WORD)-sizeof(DispBkIntens)*COL, TxOff, NULL,
467 (UBYTE *) DispBkIntens, &DispAmbient
470 struct GadExtens VBkIntens = { 0.0, 1.0, DefAmbience, 0, 0, 0, true };
473 static struct Gadget G_BkIntens = {
474 &G_PtIntens,
475 20*COL , TOP+ROW*13, COL*15, ROW, /* loc and size */
476 GadFlags,
477 RELVERIFY,
478 MyPropType,
479 NULL,
480 NULL, /* high lighted */
481 &TextBkIntens,
482 0x0,
483 NULL,
484 (int)N_BkIntens,
485 (APTR)&VBkIntens
492 * Definitions for Surface distance
495 static char DispSurfDist[] = {"Surf Dist=[ ] " };
497 static struct IntuiText TextSurfDist = {
498 1,1,JAM1, (WORD)-sizeof(DispSurfDist)*COL, TxOff, NULL,
499 (UBYTE *) DispSurfDist, NULL
503 struct GadExtens VSurfDist = {0.0, 0.0, 0.0, -500, 3000, DefSurfDist, false};
505 static struct Gadget G_SurfDist = {
506 &G_BkIntens,
507 20*COL , TOP+ROW*4, COL*15, ROW, /* loc and size */
508 GadFlags,
509 RELVERIFY,
510 MyPropType,
511 NULL,
512 NULL, /* high lighted */
513 &TextSurfDist,
514 0x0,
515 NULL,
516 (int)N_SurfDist,
517 (APTR)&VSurfDist
524 * definitions for location.x
526 static struct IntuiText PointLight = {
527 1,1,JAM1, 9*COL, -ROW*2, NULL,
528 (UBYTE *) "Point Light Source", NULL
531 static struct IntuiText TextPtLocXYZ = {
532 1,1,JAM1, -4, -ROW, NULL,
533 (UBYTE *) "Location", &PointLight
536 static char DispPtLocX[] = { "x=[ ] " };
538 static struct IntuiText TextPtLocX = {
539 1,1,JAM1, (WORD)-sizeof(DispPtLocX)*COL, TxOff, NULL,
540 (UBYTE *) DispPtLocX, &TextPtLocXYZ
544 struct GadExtens VPtLocX = {0.0, 0.0, 0.0, -6000, 6000, DefLightSrcX, false };
546 static struct Gadget G_PtLocX = {
547 &G_SurfDist,
548 12*COL , TOP+ROW*8, COL*15, ROW, /* loc and size */
549 GadFlags,
550 RELVERIFY,
551 MyPropType,
552 NULL,
553 NULL, /* high lighted */
554 &TextPtLocX,
555 0x0,
556 NULL,
557 (int)N_PtLocX,
558 (APTR) &VPtLocX
564 * definitions for location.x
567 static char DispPtLocY[] = "y=[ ] ";
569 static struct IntuiText TextPtLocY = {
570 1,1,JAM1, (WORD)-sizeof(DispPtLocY)*COL, TxOff, NULL,
571 (UBYTE *) DispPtLocY, NULL
575 struct GadExtens VPtLocY = { 0.0, 0.0, 0.0, -6000, 6000, DefLightSrcY, false };
577 static struct Gadget G_PtLocY = {
578 &G_PtLocX,
579 12*COL , TOP+ROW*9, COL*15, ROW, /* loc and size */
580 GadFlags,
581 RELVERIFY,
582 MyPropType,
583 NULL,
584 NULL, /* high lighted */
585 &TextPtLocY,
586 0x0,
587 NULL,
588 (int)N_PtLocY,
589 (APTR) &VPtLocY
595 * definitions for location.z
598 static char DispPtLocZ[] = { "z=[ ] " };
600 static struct IntuiText TextPtLocZ = {
601 1,1,JAM1, (WORD)-sizeof(DispPtLocZ)*COL, TxOff, NULL,
602 (UBYTE *)DispPtLocZ, NULL
606 struct GadExtens VPtLocZ ={ 0.0, 0.0, 0.0, -1000, 3000, DefLightSrcZ, false };
608 static struct Gadget G_PtLocZ = {
609 &G_PtLocY,
610 12*COL , TOP+ROW*10, COL*15, ROW, /* loc and size */
611 GadFlags,
612 RELVERIFY,
613 MyPropType,
614 NULL,
615 NULL, /* high lighted */
616 &TextPtLocZ,
617 0x0,
618 NULL,
619 (int)N_PtLocZ,
620 (APTR) &VPtLocZ
624 * definitions for Map replication in horizontal axis
627 static char DispRepH[] = { "Map RepH=[ ] " };
629 static struct IntuiText TextRepH = {
630 1,1,JAM1, (WORD)-sizeof(DispRepH)*COL, TxOff, NULL,
631 (UBYTE *)DispRepH, NULL
635 struct GadExtens VRepH ={ 0.0, 0.0, 0.0, 1, 300, DefRepH, false };
637 static struct Gadget G_RepH = {
638 &G_PtLocZ,
639 20*COL , TOP+ROW*15, COL*15, ROW, /* loc and size */
640 GadFlags,
641 RELVERIFY,
642 MyPropType,
643 NULL,
644 NULL, /* high lighted */
645 &TextRepH,
646 0x0,
647 NULL,
648 (int)N_RepH,
649 (APTR) &VRepH
654 * definitions for map replication in vertical axis
657 static char DispRepV[] = { "Map RepV=[ ] " };
659 static struct IntuiText TextRepV = {
660 1,1,JAM1, (WORD)-sizeof(DispRepV)*COL, TxOff, NULL,
661 (UBYTE *)DispRepV, NULL
665 struct GadExtens VRepV ={ 0.0, 0.0, 0.0, 1, 300, DefRepV, false };
667 static struct Gadget G_RepV = {
668 &G_RepH,
669 57*COL , TOP+ROW*15, COL*15, ROW, /* loc and size */
670 GadFlags,
671 RELVERIFY,
672 MyPropType,
673 NULL,
674 NULL, /* high lighted */
675 &TextRepV,
676 0x0,
677 NULL,
678 (int)N_RepV,
679 (APTR) &VRepV
687 void LoadChipMem( dest, src, srcsize)
688 UWORD **dest;
689 UWORD *src;
690 int srcsize;
692 UWORD *d;
694 d = (UWORD *)AllocMem( srcsize, MEMF_CHIP );
695 if( !d ) {
696 OutErr("not enough chip mem");
697 CloseDisplay();
698 exit(-1);
700 *dest = d;
701 while( srcsize ) {
702 *d++ = *src++;
703 srcsize -= sizeof( UWORD );
708 void InitGadgets()
710 struct Gadget *vp;
711 LoadChipMem( &HourGlass, HourGlassDat, sizeof(HourGlassDat));
714 CntrlWinDef.FirstGadget = &G_RepV;
715 GadWinDef.FirstGadget = &G_GoPanel;
717 * fill in numeric fields
719 for( vp = CntrlWinDef.FirstGadget; vp; vp = vp->NextGadget ) {
720 GadgetSetVal( vp );
721 GadgetUpdate(vp, false );
726 void EndGadgets()
728 if( HourGlass ) {
729 FreeMem(HourGlass, sizeof(HourGlassDat ));