home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / cmanual-3.0.lha / CManual / Intuition / Requesters / Example9.c < prev    next >
C/C++ Source or Header  |  1993-10-12  |  22KB  |  553 lines

  1. /***********************************************************/
  2. /*                                                         */
  3. /* Amiga C Encyclopedia (ACE) V3.0      Amiga C Club (ACC) */
  4. /* -------------------------------      ------------------ */
  5. /*                                                         */
  6. /* Book:    ACM Intuition               Amiga C Club       */
  7. /* Chapter: Requesters                  Tulevagen 22       */
  8. /* File:    Example9.c                  181 41  LIDINGO    */
  9. /* Author:  Anders Bjerin               SWEDEN             */
  10. /* Date:    92-05-01                                       */
  11. /* Version: 1.10                                           */
  12. /*                                                         */
  13. /*   Copyright 1992, Anders Bjerin - Amiga C Club (ACC)    */
  14. /*                                                         */
  15. /* Registered members may use this program freely in their */
  16. /*     own commercial/noncommercial programs/articles.     */
  17. /*                                                         */
  18. /***********************************************************/
  19.  
  20. /* This program will open a normal window which is connected to the     */
  21. /* Workbench Screen. The window will use all System Gadgets, and will   */
  22. /* close first when the user has selected the System gadget Close       */
  23. /* window. Inside the window we have activated an Application requester */
  24. /* with three connecting gadgets. Two are Boolean gadgets ("OK and      */
  25. /* "CANCEL"), and one is a Proportional gadget.                         */
  26.  
  27.  
  28.  
  29. #include <intuition/intuition.h>
  30.  
  31.  
  32.  
  33. struct IntuitionBase *IntuitionBase;
  34.  
  35.  
  36.  
  37. /*****************************************/
  38. /* THE PROPORTIONAL GADGET's STRUCTURES: */
  39. /*****************************************/
  40.  
  41. /* The IntuiText structure for the proportional gadget: */
  42. struct IntuiText prop_text=
  43. {
  44.   1,         /* FrontPen, colour register 1. */
  45.   0,         /* BackPen, colour register 0. */
  46.   JAM1,      /* DrawMode, draw the characters with colour 1, do not */
  47.              /* change the background. */ 
  48.   -65, 2,    /* LeftEdge, TopEdge. */
  49.   NULL,      /* ITextFont, use default font. */
  50.   "Colour:", /* IText, the text that will be printed. */
  51.   NULL,      /* NextText, no other IntuiText structures. */
  52. };
  53.  
  54.  
  55. /* We need to declare an Image structure for the knob, but since */
  56. /* Intuition will take care of the size etc of the knob, we do not need */
  57. /* to initialize the Image structure: */
  58. struct Image prop_image;
  59.  
  60.  
  61. struct PropInfo prop_info=
  62. {
  63.   FREEHORIZ|      /* Flags, the knob should be moved horizontally, and */
  64.   AUTOKNOB,       /* Intuition should take care of the knob image. */
  65.   0,              /* HorizPot, start position of the knob. */
  66.   0,              /* VertPot, 0 since we will not move the knob hor. */
  67.   MAXBODY * 1/16, /* HorizBody, 16 steps. */
  68.   0,              /* VertBody, 0 since we will not move the knob hor. */
  69.  
  70.   /* These variables are initialized and maintained by Intuition: */
  71.  
  72.   0,              /* CWidth */
  73.   0,              /* CHeight */
  74.   0, 0,           /* HPotRes, VPotRes */
  75.   0,              /* LeftBorder */
  76.   0               /* TopBorder */
  77. };
  78.  
  79.  
  80. struct Gadget prop_gadget=
  81. {
  82.   NULL,              /* NextGadget, no more gadgets in the list. */
  83.   80,                /* LeftEdge, 80 pixels out. */
  84.   30,                /* TopEdge, 30 lines down. */
  85.   189,               /* Width, 189 pixels wide. */
  86.   12,                /* Height, 12 pixels lines heigh. */
  87.   GADGHCOMP,         /* Flags, complement the colours. */
  88.   GADGIMMEDIATE|     /* Activation, our program will recieve a message */
  89.   RELVERIFY,         /* when the user has selected this gadget, and when */
  90.                      /* the user has released it. */ 
  91.   PROPGADGET,        /* GadgetType, a Proportional gadget. */
  92.   (APTR) &prop_image,/* GadgetRender, a pointer to our Image structure. */
  93.                      /* (Intuition will take care of the knob image) */
  94.                      /* (See chapter 3 GRAPHICS for more information) */
  95.   NULL,              /* SelectRender, NULL since we do not supply the */
  96.                      /* gadget with an alternative image. */
  97.   &prop_text,        /* GadgetText, colour. */
  98.   NULL,              /* MutualExclude, no mutual exclude. */
  99.   (APTR) &prop_info, /* SpecialInfo, pointer to a PropInfo structure. */
  100.   0,                 /* GadgetID, no id. */
  101.   NULL               /* UserData, no user data connected to the gadget. */
  102. };
  103.  
  104.  
  105.  
  106. /*******************************/
  107. /* THE OK GADGET's STRUCTURES: */
  108. /*******************************/
  109.  
  110. /* The coordinates for the OK box: */
  111. SHORT ok_border_points[]=
  112. {
  113.    0,  0, /* Start at position (0,0) */
  114.   22,  0, /* Draw a line to the right to position (22,0) */
  115.   22, 10, /* Draw a line down to position (22,10) */
  116.    0, 10, /* Draw a line to the left to position (0,10) */
  117.    0,  0  /* Finish of by drawing a line up to position (0,0) */ 
  118. };
  119.  
  120. /* The Border structure: */
  121. struct Border ok_border=
  122. {
  123.   0, 0,        /* LeftEdge, TopEdge. */
  124.   1,           /* FrontPen, colour register 1. */
  125.   0,           /* BackPen, for the moment unused. */
  126.   JAM1,        /* DrawMode, draw the lines with colour 1. */
  127.   5,           /* Count, 5 pair of coordinates in the array. */
  128.   ok_border_points, /* XY, pointer to the array with the coord. */
  129.   NULL,        /* NextBorder, no other Border structures are connected. */
  130. };
  131.  
  132. /* The IntuiText structure: */
  133. struct IntuiText ok_text=
  134. {
  135.   1,      /* FrontPen, colour register 1. */
  136.   0,      /* BackPen, not used since JAM1. */
  137.   JAM1,   /* DrawMode, draw the characters with colour 1, do not */
  138.           /* change the background. */ 
  139.   4, 2,   /* LeftEdge, TopEdge. */
  140.   NULL,   /* ITextFont, use default font. */
  141.   "OK",   /* IText, the text that will be printed. */
  142.   NULL,   /* NextText, no other IntuiText structures are connected. */
  143. };
  144.  
  145. struct Gadget ok_gadget=
  146. {
  147.   &prop_gadget,  /* NextGadget, linked to the Proportional gadget. */
  148.   14,            /* LeftEdge, 14 pixels out. */
  149.   47,            /* TopEdge, 47 lines down. */
  150.   23,            /* Width, 23 pixels wide. */
  151.   11,            /* Height, 11 pixels lines heigh. */
  152.   GADGHCOMP,     /* Flags, when this gadget is highlighted, the gadget */
  153.                  /* will be rendered in the complement colours. */
  154.                  /* (Colour 0 (00) will be changed to colour 3 (11) */
  155.                  /* (Colour 1 (01)           - " -           2 (10) */
  156.                  /* (Colour 2 (10)           - " -           1 (01) */
  157.                  /* (Colour 3 (11)           - " -           0 (00) */  
  158.   GADGIMMEDIATE| /* Activation, our program will recieve a message when */
  159.   RELVERIFY|     /* the user has selected this gadget, and when the user */
  160.                  /* has released it. */
  161.   ENDGADGET,     /* When the user has selected this gadget, the */
  162.                  /* requester is satisfied, and is deactivated. */
  163.                  /* IMPORTANT! At least one gadget per requester */
  164.                  /* must have the flag ENDGADGET set. If not, the */
  165.                  /* requester would never be deactivated! */
  166.  
  167.   BOOLGADGET|    /* GadgetType, a Boolean gadget which is connected to */
  168.   REQGADGET,     /* a requester. IMPORTANT! Every gadget which is */
  169.                  /* connectd to a requester must have the REQGADGET flsg */
  170.                  /* set in the GadgetType field. */
  171.   (APTR) &ok_border, /* GadgetRender, a pointer to our Border struc. */
  172.   NULL,          /* SelectRender, NULL since we do not supply the gadget */
  173.                  /* with an alternative image. (We complement the */
  174.                  /* colours instead) */
  175.   &ok_text,      /* GadgetText, a pointer to our IntuiText structure. */
  176.                  /* (See chapter 3 GRAPHICS for more information) */
  177.   NULL,          /* MutualExclude, no mutual exclude. */
  178.   NULL,          /* SpecialInfo, NULL since this is a Boolean gadget. */
  179.                  /* (No binary mask) */
  180.   0,             /* GadgetID, no id. */
  181.   NULL           /* UserData, no user data connected to the gadget. */
  182. };
  183.  
  184.  
  185.  
  186. /***********************************/
  187. /* THE CANCEL GADGET's STRUCTURES: */
  188. /***********************************/
  189.  
  190. /* The coordinates for the