grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / demos / demowin.c
blobc2ee16d3d7e0825d6f2ac9f33dd6776815d78a27
1 /*
2 Copyright © 1995-96, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: A short demo for the features of Intuition and Graphics
6 Lang: english
7 */
8 #define ENABLE_RT 1
9 #define ENABLE_PURIFY 1
11 #include <exec/memory.h>
12 #include <dos/dos.h>
13 #include <dos/exall.h>
14 #include <dos/datetime.h>
15 #include <proto/exec.h>
16 #include <proto/dos.h>
17 #include <proto/arossupport.h>
18 #include <proto/alib.h>
19 #include <proto/utility.h>
20 #include <proto/graphics.h>
21 #include <proto/intuition.h>
22 #include <proto/console.h>
23 #include <intuition/intuitionbase.h>
24 #include <intuition/intuition.h>
25 #include <graphics/gfxbase.h>
26 #include <graphics/rastport.h>
27 #include <graphics/gfxmacros.h>
28 #include <ctype.h>
29 #include <stdio.h>
30 #include <aros/rt.h>
31 #include <intuition/classusr.h>
32 #include <intuition/gadgetclass.h>
33 #include <intuition/imageclass.h>
34 #include <devices/keymap.h>
36 #if 0
37 # define D(x) x
38 #else
39 # define D(x) /* eps */
40 #endif
41 #define bug kprintf
43 static const char version[] __attribute__((used)) = "$VER: demowin 41.1 (14.3.1997)\n";
45 struct Device *ConsoleDevice;
46 struct IntuitionBase *IntuitionBase;
47 struct GfxBase *GfxBase;
48 Object * frame, * gadget;
50 void Refresh (struct RastPort * rp)
52 int len;
53 int t, tend, pen;
54 int x, y;
55 WORD xy[8];
57 SetAPen (rp, 1);
58 SetDrMd (rp, JAM2);
60 Move (rp, 0, 0);
61 Draw (rp, 320, 150);
63 Move (rp, 640, 0);
64 Draw (rp, 0, 300);
66 SetDrPt (rp, 0xF0F0);
67 len = 150;
68 x = 340;
69 y = 150;
71 xy[0] = x; xy[1] = y+len;
72 xy[2] = x+len; xy[3] = y+len;
73 xy[4] = x; xy[5] = y;
74 Move(rp,x,y);
75 PolyDraw (rp, 3, xy);
77 SetDrPt (rp, 0xAAAA);
78 x += 10;
79 y += 20;
80 len -= 30;
81 xy[0] = x; xy[1] = y+len;
82 xy[2] = x+len; xy[3] = y+len;
83 xy[4] = x; xy[5] = y;
84 Move(rp,x,y);
85 PolyDraw (rp, 3, xy);
87 SetDrPt (rp, 0x3333);
88 x += 10;
89 y += 20;
90 len -= 30;
91 xy[0] = x; xy[1] = y+len;
92 xy[2] = x+len; xy[3] = y+len;
93 xy[4] = x; xy[5] = y;
94 Move(rp,x,y);
95 PolyDraw (rp, 3, xy);
97 SetDrPt (rp, 0xF731);
98 x += 10;
99 y += 20;
100 len -= 30;
101 xy[0] = x; xy[1] = y;
102 xy[2] = x; xy[3] = y+len;
103 xy[4] = x+len; xy[5] = y+len;
104 xy[6] = x; xy[7] = y;
105 PolyDraw (rp, 4, xy);
107 SetDrPt (rp, ~0);
109 Move (rp, 300, 40);
110 Text (rp, "Hello World.", 12);
112 SetAPen (rp, 3);
113 RectFill (rp, 90, 0, 120, 30);
114 SetAPen (rp, 0);
115 RectFill (rp, 100, 10, 110, 20);
117 SetAPen (rp, 1);
118 RectFill (rp, 150, 10, 160, 20);
120 SetAPen (rp, 2);
121 RectFill (rp, 200, 10, 210, 20);
123 SetAPen (rp, 3);
124 RectFill (rp, 250, 10, 260, 20);
126 len = TextLength (rp, "Hello World.", 12);
128 SetAPen (rp, 2);
129 RectFill (rp, 299, 59, 300+len, 60+rp->Font->tf_YSize);
131 SetAPen (rp, 1);
132 Move (rp, 300, 60 + rp->Font->tf_Baseline);
133 Text (rp, "Hello World.", 12);
135 SetDrMd (rp, JAM1);
136 SetAPen (rp, 1);
137 Move (rp, 301, 101);
138 Text (rp, "Hello World.", 12);
139 SetAPen (rp, 2);
140 Move (rp, 300, 100);
141 Text (rp, "Hello World.", 12);
143 Move (rp, 20, 350);
144 Text (rp, "Press \"Complement\" to flip PropGadgets", 39);
146 tend = 10;
147 t = 0;
149 for (pen=1; pen<16; pen++)
151 SetAPen (rp, pen);
153 for ( ; t<tend; t++)
155 DrawEllipse (rp, 160, 150, t, t>>1);
156 DrawEllipse (rp, 160, 151, t, t>>1);
159 tend += 10;
162 SetAPen (rp, 0);
163 RectFill (rp, 450, 140, 549, 239);
165 for (y=0; y<20; y++)
167 for (x=0; x<100; x++)
169 pen = (LONG)ReadPixel (rp, x+100,y+100);
170 SetAPen (rp, pen);
171 WritePixel (rp, x+450, y+140);
176 #define GAD_WID 100
177 #define GAD_HEI 30
178 #define BORDER 20
180 WORD BorderData[6*2*2] =
182 0, GAD_HEI-1, /* Top (lighter) edge */
183 1, GAD_HEI-2,
184 1, 1,
185 GAD_WID-2, 1,
186 GAD_WID-1, 0,
187 0, 0,
189 0, -(GAD_HEI-2), /* Bottom (darker) edge */
190 -1, -(GAD_HEI-3),
191 -1, -1,
192 -(GAD_WID-3), -1,
193 -(GAD_WID-2), 0,
194 -1, 0,
196 struct Border
197 DemoBottomBorder =
199 GAD_WID-1, GAD_HEI-1,
200 1, 2,
201 JAM1,
203 &BorderData[6*2],
204 NULL
206 DemoTopBorder =
208 0, 0,
209 2, 1,
210 JAM1,
212 &BorderData[0],
213 &DemoBottomBorder
215 struct Border DemoIBottomBorder =
217 GAD_WID-1, GAD_HEI-1,
218 2, 1,
219 JAM1,
221 &BorderData[6*2],
222 NULL
224 DemoITopBorder =
226 0, 0,
227 1, 2,
228 JAM1,
230 &BorderData[0],
231 &DemoIBottomBorder
234 struct PropInfo
235 DemoPropInfo1 =
237 AUTOKNOB | FREEHORIZ | PROPNEWLOOK,
238 0, 0,
239 MAXBODY, MAXBODY,
240 0,0,0,0,0,0
242 DemoPropInfo2 =
244 AUTOKNOB | FREEVERT | PROPNEWLOOK,
245 0, 0,
246 MAXBODY, MAXBODY,
247 0,0,0,0,0,0
249 DemoPropInfo3 =
251 AUTOKNOB | FREEHORIZ | FREEVERT | PROPNEWLOOK,
252 0, 0,
253 MAXBODY, MAXBODY,
254 0,0,0,0,0,0
257 struct IntuiText
258 DemoIText =
260 1, 2, /* Pens */
261 JAM1, /* Drawmode */
262 0, 0, /* Left, Top */
263 NULL, /* TextAttr */
264 "None", /* Text */
265 NULL /* Next */
268 #include "images/ArrowUp0.h"
269 #include "images/ArrowUp1.h"
270 #include "images/ArrowDown0.h"
271 #include "images/ArrowDown1.h"
272 #include "images/ArrowLeft0.h"
273 #include "images/ArrowLeft1.h"
274 #include "images/ArrowRight0.h"
275 #include "images/ArrowRight1.h"
276 #include "images/ImageButton0.h"
277 #include "images/ImageButton1.h"
279 struct Gadget
280 DemoGadget12 =
282 NULL, /* &DemoGadget, / * NextGadget */
283 -(BORDER+2*ARROWLEFT1_WIDTH), -((GAD_HEI+BORDER)*3),
284 ARROWLEFT1_WIDTH, ARROWLEFT1_HEIGHT, /* hit box */
285 GFLG_GADGHIMAGE
286 | GFLG_RELRIGHT
287 | GFLG_RELBOTTOM
288 | GFLG_GADGIMAGE
289 , /* Flags */
290 GACT_IMMEDIATE | GACT_RELVERIFY, /* Activation */
291 GTYP_BOOLGADGET, /* Type */
292 &ArrowLeft0Image, &ArrowLeft1Image, /* Render */
293 NULL, /* Text */
294 0L, NULL, /* MutualExcl, SpecialInfo */
295 13, /* GadgetID */
296 NULL /* UserData */
298 DemoGadget11 =
300 &DemoGadget12, /* NextGadget */
301 -(BORDER+1*ARROWLEFT1_WIDTH), -((GAD_HEI+BORDER)*3),
302 ARROWLEFT1_WIDTH, ARROWLEFT1_HEIGHT, /* hit box */
303 GFLG_GADGHIMAGE
304 | GFLG_RELRIGHT
305 | GFLG_RELBOTTOM
306 | GFLG_GADGIMAGE
307 , /* Flags */
308 GACT_IMMEDIATE | GACT_RELVERIFY, /* Activation */
309 GTYP_BOOLGADGET, /* Type */
310 &ArrowRight0Image, &ArrowRight1Image, /* Render */
311 NULL, /* Text */
312 0L, NULL, /* MutualExcl, SpecialInfo */
313 12, /* GadgetID */
314 NULL /* UserData */
316 DemoGadget10 =
318 &DemoGadget11, /* NextGadget */
319 -(BORDER+ARROWDOWN1_WIDTH), -((GAD_HEI+BORDER)*3+ARROWLEFT1_HEIGHT+0*ARROWDOWN1_HEIGHT-5),
320 ARROWDOWN1_WIDTH, ARROWDOWN1_HEIGHT, /* hit box */
321 GFLG_GADGHIMAGE
322 | GFLG_RELRIGHT
323 | GFLG_RELBOTTOM
324 | GFLG_GADGIMAGE
325 , /* Flags */
326 GACT_IMMEDIATE | GACT_RELVERIFY, /* Activation */
327 GTYP_BOOLGADGET, /* Type */
328 &ArrowDown0Image, &ArrowDown1Image, /* Render */
329 NULL, /* Text */
330 0L, NULL, /* MutualExcl, SpecialInfo */
331 11, /* GadgetID */
332 NULL /* UserData */
334 DemoGadget9 =
336 &DemoGadget10, /* NextGadget */
337 -(BORDER+ARROWDOWN1_WIDTH), -((GAD_HEI+BORDER)*3+ARROWLEFT1_HEIGHT+1*ARROWDOWN1_HEIGHT-5),
338 ARROWDOWN1_WIDTH, ARROWDOWN1_HEIGHT, /* hit box */
339 GFLG_GADGHIMAGE
340 | GFLG_RELRIGHT
341 | GFLG_RELBOTTOM
342 | GFLG_GADGIMAGE
343 , /* Flags */
344 GACT_IMMEDIATE | GACT_RELVERIFY, /* Activation */
345 GTYP_BOOLGADGET, /* Type */
346 &ArrowUp0Image, &ArrowUp1Image, /* Render */
347 NULL, /* Text */
348 0L, NULL, /* MutualExcl, SpecialInfo */
349 10, /* GadgetID */
350 NULL /* UserData */
352 DemoGadget8 =
354 &DemoGadget9, /* NextGadget */
355 -(BORDER+ARROWDOWN1_WIDTH+GAD_WID), -((GAD_HEI+BORDER)*3+GAD_WID),
356 GAD_WID, GAD_WID, /* hit box */
357 GFLG_GADGHIMAGE
358 | GFLG_RELRIGHT
359 | GFLG_RELBOTTOM
360 , /* Flags */
361 GACT_IMMEDIATE
362 | GACT_RELVERIFY
363 | GACT_TOGGLESELECT
364 , /* Activation */
365 GTYP_PROPGADGET, /* Type */
366 NULL, NULL, /* Render */
367 NULL, /* Text */
368 0L, (APTR)&DemoPropInfo3, /* MutualExcl, SpecialInfo */
369 9, /* GadgetID */
370 NULL /* UserData */
372 DemoGadget7 =
374 &DemoGadget8, /* NextGadget */
375 -(BORDER+ARROWDOWN1_WIDTH), BORDER,
376 ARROWDOWN1_WIDTH, -(GAD_HEI*3+BORDER*4+2*ARROWDOWN1_HEIGHT), /* hit box */
377 GFLG_GADGHIMAGE
378 | GFLG_RELRIGHT
379 | GFLG_RELHEIGHT
380 , /* Flags */
381 GACT_IMMEDIATE
382 | GACT_RELVERIFY
383 | GACT_TOGGLESELECT
384 , /* Activation */
385 GTYP_PROPGADGET, /* Type */
386 NULL, NULL, /* Render */
387 NULL, /* Text */
388 0L, (APTR)&DemoPropInfo2, /* MutualExcl, SpecialInfo */
389 8, /* GadgetID */
390 NULL /* UserData */
392 DemoGadget6 =
394 &DemoGadget7, /* NextGadget */
395 BORDER, -((GAD_HEI+BORDER)*3),
396 -(1+2*BORDER+2*ARROWLEFT0_WIDTH), ARROWLEFT0_HEIGHT, /* hit box */
397 GFLG_GADGHIMAGE
398 | GFLG_RELBOTTOM
399 | GFLG_RELWIDTH
400 , /* Flags */
401 GACT_IMMEDIATE
402 | GACT_RELVERIFY
403 | GACT_TOGGLESELECT
404 , /* Activation */
405 GTYP_PROPGADGET, /* Type */
406 NULL, NULL, /* Render */
407 NULL, /* Text */
408 0L, (APTR)&DemoPropInfo1, /* MutualExcl, SpecialInfo */
409 7, /* GadgetID */
410 NULL /* UserData */
412 DemoGadget5 =
414 &DemoGadget6, /* NextGadget */
415 BORDER+(GAD_WID+BORDER)*4, -((GAD_HEI+BORDER)*2), GAD_WID, GAD_HEI, /* hit box */
416 GFLG_GADGHIMAGE
417 | GFLG_LABELSTRING
418 | GFLG_RELBOTTOM
419 , /* Flags */
420 GACT_IMMEDIATE
421 | GACT_RELVERIFY
422 | GACT_TOGGLESELECT
423 , /* Activation */
424 GTYP_BOOLGADGET, /* Type */
425 &DemoTopBorder, &DemoITopBorder, /* Render */
426 (struct IntuiText *)"_Toggle", /* Text */
427 0L, NULL, /* MutualExcl, SpecialInfo */
428 6, /* GadgetID */
429 NULL /* UserData */
431 DemoGadget4 =
433 &DemoGadget5, /* NextGadget */
434 BORDER+(GAD_WID+BORDER)*3, -((GAD_HEI+BORDER)*2), GAD_WID, GAD_HEI, /* hit box */
435 GFLG_GADGHNONE
436 | GFLG_LABELITEXT
437 | GFLG_RELBOTTOM
438 , /* Flags */
439 GACT_IMMEDIATE | GACT_RELVERIFY, /* Activation */
440 GTYP_BOOLGADGET, /* Type */
441 &DemoTopBorder, NULL, /* Render */
442 &DemoIText, /* Text */
443 0L, NULL, /* MutualExcl, SpecialInfo */
444 5, /* GadgetID */
445 NULL /* UserData */
447 DemoGadget3 =
449 &DemoGadget4, /* NextGadget */
450 BORDER+(GAD_WID+BORDER)*2, -((GAD_HEI+BORDER)*2),
451 IMAGEBUTTON0_WIDTH, IMAGEBUTTON0_HEIGHT, /* hit box */
452 GFLG_GADGHIMAGE
453 | GFLG_LABELSTRING
454 | GFLG_RELBOTTOM
455 | GFLG_GADGIMAGE
456 , /* Flags */
457 GACT_IMMEDIATE | GACT_RELVERIFY, /* Activation */
458 GTYP_BOOLGADGET, /* Type */
459 &ImageButton0Image, &ImageButton1Image, /* Render */
460 (struct IntuiText *)"_Image", /* Text */
461 0L, NULL, /* MutualExcl, SpecialInfo */
462 4, /* GadgetID */
463 NULL /* UserData */
465 DemoGadget2 =
467 &DemoGadget3, /* NextGadget */
468 BORDER+(GAD_WID+BORDER)*1, -((GAD_HEI+BORDER)*2), GAD_WID, GAD_HEI, /* hit box */
469 GFLG_GADGHBOX
470 | GFLG_LABELSTRING
471 | GFLG_RELBOTTOM
472 , /* Flags */
473 GACT_IMMEDIATE | GACT_RELVERIFY, /* Activation */
474 GTYP_BOOLGADGET, /* Type */
475 &DemoTopBorder, NULL, /* Render */
476 (struct IntuiText *)"_Box", /* Text */
477 0L, NULL, /* MutualExcl, SpecialInfo */
478 3, /* GadgetID */
479 NULL /* UserData */
481 DemoGadget1 =
483 &DemoGadget2, /* NextGadget */
484 BORDER+(GAD_WID+BORDER)*0, -((GAD_HEI+BORDER)*2), GAD_WID, GAD_HEI, /* hit box */
485 GFLG_GADGHCOMP
486 | GFLG_LABELSTRING
487 | GFLG_RELBOTTOM
488 , /* Flags */
489 GACT_IMMEDIATE | GACT_RELVERIFY, /* Activation */
490 GTYP_BOOLGADGET, /* Type */
491 &DemoTopBorder, NULL, /* Render */
492 (struct IntuiText *)"_Complement", /* Text */
493 0L, NULL, /* MutualExcl, SpecialInfo */
494 2, /* GadgetID */
495 NULL /* UserData */
497 ExitGadget =
499 &DemoGadget1, /* NextGadget */
500 BORDER, -(GAD_HEI+BORDER), GAD_WID, GAD_HEI, /* hit box */
501 GFLG_GADGHIMAGE
502 | GFLG_LABELSTRING
503 | GFLG_RELBOTTOM
504 , /* Flags */
505 GACT_RELVERIFY, /* Activation */
506 GTYP_BOOLGADGET, /* Type */
507 &DemoTopBorder, &DemoITopBorder, /* Render */
508 (struct IntuiText *)"E_xit", /* Text */
509 0L, NULL, /* MutualExcl, SpecialInfo */
510 1, /* GadgetID */
511 NULL /* UserData */
514 int main (int argc, char ** argv)
516 struct Window * win;
517 struct RastPort * rp;
518 struct IntuiMessage * im;
519 struct IOStdReq cioreq;
520 struct InputEvent ievent =
522 NULL,
523 IECLASS_RAWKEY,
524 /* ... */
526 int cont, draw;
527 int prop;
529 RT_Init ();
531 printf ("Welcome to the window demo of AROS\n");
533 GfxBase=(struct GfxBase *)OpenLibrary(GRAPHICSNAME,39);
534 IntuitionBase=(struct IntuitionBase *)OpenLibrary(INTUITIONNAME,39);
536 if (!GfxBase)
538 fprintf (stderr, "Couldn't open %s\n", GRAPHICSNAME);
539 goto end;
542 if (!IntuitionBase)
544 fprintf (stderr, "Couldn't open %s\n", INTUITIONNAME);
545 goto end;
548 cioreq.io_Message.mn_Length = sizeof(struct IOStdReq);
550 OpenDevice ("console.device", -1, (struct IORequest *)&cioreq, 0);
551 ConsoleDevice = cioreq.io_Device;
552 printf ("Opening console.device=%p (%s)\n", ConsoleDevice,
553 ConsoleDevice && ConsoleDevice->dd_Library.lib_Node.ln_Name ?
554 (const char *)ConsoleDevice->dd_Library.lib_Node.ln_Name :
555 "(NULL)");
557 if (!ConsoleDevice)
559 fprintf (stderr, "Couldn't open console\n");
560 return 10;
563 frame = NewObject (NULL, FRAMEICLASS
564 , IA_Width, GAD_WID
565 , IA_Height, GAD_HEI
566 , TAG_END
569 gadget = NewObject (NULL, FRBUTTONCLASS
570 , GA_Left, BORDER*2+GAD_WID
571 , GA_RelBottom, -(GAD_HEI+BORDER)
572 , GA_Width, GAD_WID
573 , GA_Height, GAD_HEI
574 , GA_Previous, (IPTR)&DemoGadget12
575 , GA_Text, (IPTR)"_Exit"
576 , GA_RelVerify, TRUE
577 , GA_ID, 1
578 , GA_Image, (IPTR)frame
579 , TAG_END
582 win = OpenWindowTags (NULL
583 , WA_Title, (IPTR)"Open a window demo"
584 , WA_Left, 100
585 , WA_Top, 50
586 , WA_Width, 640
587 , WA_Height, 512
588 , WA_DragBar, TRUE
589 , WA_CloseGadget, TRUE
590 , WA_DepthGadget, TRUE
591 , WA_IDCMP, IDCMP_RAWKEY
592 | IDCMP_REFRESHWINDOW
593 | IDCMP_MOUSEBUTTONS
594 | IDCMP_MOUSEMOVE
595 | IDCMP_GADGETDOWN
596 | IDCMP_GADGETUP
597 | IDCMP_CLOSEWINDOW
598 , WA_SimpleRefresh, TRUE
599 , WA_Gadgets, (IPTR)&ExitGadget
600 , TAG_END
602 D(printf("OpenWindow win=%p\n", win));
604 if (!win)
606 fprintf (stderr, "Couldn't open window\n");
607 return 10;
610 rp = win->RPort;
612 DemoIText.LeftEdge = GAD_WID/2 - rp->Font->tf_XSize*2;
613 DemoIText.TopEdge = GAD_HEI/2 - rp->Font->tf_YSize/2;
614 RefreshGList(&DemoGadget4,win,NULL,1);
616 if (!gadget)
617 printf ("Warning: Couldn't create gadget\n");
619 if (!frame)
620 printf ("Warning: Couldn't create frame\n");
622 cont = 1;
623 draw = 0;
624 prop = 0;
626 /* Refresh the window contents */
627 Refresh(win->RPort);
629 while (cont)
631 if ((im = (struct IntuiMessage *)GetMsg (win->UserPort)))
633 /* D("Got msg\n"); */
634 switch (im->Class)
636 case IDCMP_CLOSEWINDOW:
637 cont = 0;
638 break;
640 case IDCMP_RAWKEY: {
641 UBYTE buf[10];
642 int len;
643 int t;
645 ievent.ie_Code = im->Code;
646 ievent.ie_Qualifier = im->Qualifier;
648 len = RawKeyConvert (&ievent, buf, sizeof (buf), NULL);
650 printf ("Key %s %3ld + Qual %08lx=\""
651 , (im->Code & 0x8000) ? "up " : "down"
652 , (long)(im->Code & 0xFF)
653 , (unsigned long)im->Qualifier
656 if (len < 0)
658 printf ("\" (buffer too short)");
659 break;
662 for (t=0; t<len; t++)
664 if (buf[t] < 32 || (buf[t] >= 127 && buf[t] < 160))
666 switch (buf[t])
668 case '\n':
669 printf ("\\n");
670 break;
672 case '\t':
673 printf ("\\t");
674 break;
676 case '\b':
677 printf ("\\b");
678 break;
680 case '\r':
681 printf ("\\r");
682 break;
684 case 0x1B:
685 printf ("^[");
686 break;
688 default:
689 printf ("\\x%02x", buf[t]);
690 break;
691 } /* switch */
693 else
694 putc (buf[t], stdout);
696 printf ("\"\n");
698 if (*buf == '\x1b' && len == 1)
700 if (len == 1)
701 cont = 0;
704 break; }
706 case IDCMP_MOUSEBUTTONS:
707 switch (im->Code)
709 case SELECTDOWN:
710 SetAPen (rp, 2);
711 Move (rp, im->MouseX, im->MouseY);
712 draw = 1;
713 break;
715 case SELECTUP:
716 draw = 0;
717 break;
719 case MIDDLEDOWN:
720 SetAPen (rp, 1);
721 Move (rp, im->MouseX, im->MouseY);
722 draw = 1;
723 break;
725 case MIDDLEUP:
726 draw = 0;
727 break;
729 case MENUDOWN:
730 SetAPen (rp, 3);
731 Move (rp, im->MouseX, im->MouseY);
732 draw = 1;
733 break;
735 case MENUUP:
736 draw = 0;
737 break;
741 break;
743 case IDCMP_MOUSEMOVE:
744 if (draw)
745 Draw (rp, im->MouseX, im->MouseY);
747 break;
749 case IDCMP_REFRESHWINDOW:
750 printf ("REFRESHWINDOW\n");
751 BeginRefresh (win);
752 Refresh (rp);
753 EndRefresh (win, TRUE);
754 break;
756 case IDCMP_GADGETDOWN: {
757 struct Gadget * gadget;
758 LONG pot;
760 gadget = (struct Gadget *)im->IAddress;
762 printf ("User pressed gadget %d\n", gadget->GadgetID);
764 switch (gadget->GadgetID)
766 case 10: /* Up */
767 pot = DemoPropInfo3.VertPot - DemoPropInfo3.VertBody;
769 if (pot < 0)
770 pot = 0;
772 NewModifyProp (&DemoGadget7
773 , win
774 , NULL
775 , DemoPropInfo2.Flags
776 , DemoPropInfo2.HorizPot
777 , pot
778 , DemoPropInfo2.HorizBody
779 , DemoPropInfo2.VertBody
782 NewModifyProp (&DemoGadget8
783 , win
784 , NULL
785 , DemoPropInfo3.Flags
786 , DemoPropInfo3.HorizPot
787 , pot
788 , DemoPropInfo3.HorizBody
789 , DemoPropInfo3.VertBody
793 break;
795 case 11: /* Down */
796 pot = DemoPropInfo3.VertPot + DemoPropInfo3.VertBody;
798 if (pot > MAXPOT)
799 pot = MAXPOT;
801 NewModifyProp (&DemoGadget7
802 , win
803 , NULL
804 , DemoPropInfo2.Flags
805 , DemoPropInfo2.HorizPot
806 , pot
807 , DemoPropInfo2.HorizBody
808 , DemoPropInfo2.VertBody
811 NewModifyProp (&DemoGadget8
812 , win
813 , NULL
814 , DemoPropInfo3.Flags
815 , DemoPropInfo3.HorizPot
816 , pot
817 , DemoPropInfo3.HorizBody
818 , DemoPropInfo3.VertBody
822 break;
824 case 12: /* Right */
825 pot = DemoPropInfo1.HorizPot + DemoPropInfo1.HorizBody;
827 if (pot > MAXPOT)
828 pot = MAXPOT;
830 NewModifyProp (&DemoGadget6
831 , win
832 , NULL
833 , DemoPropInfo1.Flags
834 , pot
835 , DemoPropInfo1.VertPot
836 , DemoPropInfo1.HorizBody
837 , DemoPropInfo1.VertBody
840 NewModifyProp (&DemoGadget8
841 , win
842 , NULL
843 , DemoPropInfo3.Flags
844 , pot
845 , DemoPropInfo3.VertPot
846 , DemoPropInfo3.HorizBody
847 , DemoPropInfo3.VertBody
851 break;
853 case 13: /* Left */
854 pot = DemoPropInfo1.HorizPot - DemoPropInfo1.HorizBody;
856 if (pot < 0)
857 pot = 0;
859 NewModifyProp (&DemoGadget6
860 , win
861 , NULL
862 , DemoPropInfo1.Flags
863 , pot
864 , DemoPropInfo1.VertPot
865 , DemoPropInfo1.HorizBody
866 , DemoPropInfo1.VertBody
869 NewModifyProp (&DemoGadget8
870 , win
871 , NULL
872 , DemoPropInfo3.Flags
873 , pot
874 , DemoPropInfo3.VertPot
875 , DemoPropInfo3.HorizBody
876 , DemoPropInfo3.VertBody
880 break;
884 break; }
886 case IDCMP_GADGETUP: {
887 struct Gadget * gadget;
889 gadget = (struct Gadget *)im->IAddress;
891 printf ("User released gadget %d\n", gadget->GadgetID);
893 if (gadget->GadgetID == 1)
894 cont = 0;
895 else if (gadget->GadgetID == 2)
897 prop ++;
899 switch (prop)
901 case 0:
902 NewModifyProp (&DemoGadget6, win, NULL,
903 DemoPropInfo1.Flags,
904 0, 0, MAXBODY, MAXBODY, 1);
905 NewModifyProp (&DemoGadget7, win, NULL,
906 DemoPropInfo2.Flags,
907 0, 0, MAXBODY, MAXBODY, 1);
908 NewModifyProp (&DemoGadget8, win, NULL,
909 DemoPropInfo3.Flags,
910 0, 0, MAXBODY, MAXBODY, 1);
911 break;
913 case 1:
914 NewModifyProp (&DemoGadget6, win, NULL,
915 DemoPropInfo1.Flags,
916 0, 0, MAXBODY/2, MAXBODY, 1);
917 NewModifyProp (&DemoGadget7, win, NULL,
918 DemoPropInfo2.Flags,
919 0, 0, MAXBODY, MAXBODY/2, 1);
920 NewModifyProp (&DemoGadget8, win, NULL,
921 DemoPropInfo3.Flags,
922 0, 0, MAXBODY/2, MAXBODY/2, 1);
923 break;
925 case 2:
926 NewModifyProp (&DemoGadget6, win, NULL,
927 DemoPropInfo1.Flags,
928 MAXPOT, 0, MAXBODY/2, MAXBODY, 1);
929 NewModifyProp (&DemoGadget7, win, NULL,
930 DemoPropInfo2.Flags,
931 0, MAXPOT, MAXBODY, MAXBODY/2, 1);
932 NewModifyProp (&DemoGadget8, win, NULL,
933 DemoPropInfo3.Flags,
934 MAXPOT, MAXPOT, MAXBODY/2, MAXBODY/2, 1);
935 break;
937 default:
938 NewModifyProp (&DemoGadget6, win, NULL,
939 DemoPropInfo1.Flags,
940 0, 0, MAXBODY/9, MAXBODY, 1);
941 NewModifyProp (&DemoGadget7, win, NULL,
942 DemoPropInfo2.Flags,
943 0, 0, MAXBODY, MAXBODY/9, 1);
944 NewModifyProp (&DemoGadget8, win, NULL,
945 DemoPropInfo3.Flags,
946 0, 0, MAXBODY/9, MAXBODY/9, 1);
947 prop = -1;
948 break;
953 break; }
955 } /* switch */
957 ReplyMsg ((struct Message *)im);
959 else
961 /* D("Waiting\n"); */
962 Wait (1L << win->UserPort->mp_SigBit);
966 D(bug("CloseWindow (%p)\n", win));
967 CloseWindow (win);
969 end:
970 if (gadget)
971 DisposeObject (gadget);
973 if (frame)
974 DisposeObject (frame);
976 if (GfxBase)
977 CloseLibrary ((struct Library *)GfxBase);
979 if (IntuitionBase)
980 CloseLibrary ((struct Library *)IntuitionBase);
982 if (ConsoleDevice)
983 CloseDevice ((struct IORequest *)&cioreq);
985 RT_Exit ();
987 return 0;