home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / cmanual-3.0.lha / CManual / Intuition / Requesters / Example6.c < prev    next >
C/C++ Source or Header  |  1993-10-12  |  17KB  |  418 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:    Example6.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. Whenever the user double-clicks on the right mouse button,   */
  24. /* we will recieve a REQVERIFY message, and first when we have replied, */
  25. /* will the requester be activated.                                     */
  26.  
  27.  
  28.  
  29. #include <intuition/intuition.h>
  30.  
  31.  
  32.  
  33. struct IntuitionBase *IntuitionBase;
  34.  
  35.  
  36.  
  37. /***************/
  38. /* THE GADGET: */
  39. /***************/
  40.  
  41. /* The coordinates for the box: */
  42. SHORT gadget_border_points[]=
  43. {
  44.    0,  0, /* Start at position (0,0) */
  45.   70,  0, /* Draw a line to the right to position (70,0) */
  46.   70, 10, /* Draw a line down to position (70,10) */
  47.    0, 10, /* Draw a line to the right to position (0,10) */
  48.    0,  0  /* Finish of by drawing a line up to position (0,0) */ 
  49. };
  50.  
  51. /* The Border structure: */
  52. struct Border gadget_border=
  53. {
  54.   0, 0,        /* LeftEdge, TopEdge. */
  55.   1,           /* FrontPen, colour register 1. */
  56.   0,           /* BackPen, for the moment unused. */
  57.   JAM1,        /* DrawMode, draw the lines with colour 1. */
  58.   5,           /* Count, 5 pair of coordinates in the array. */
  59.   gadget_border_points, /* XY, pointer to the array with the coord. */
  60.   NULL,        /* NextBorder, no other Border structures are connected. */
  61. };
  62.  
  63. /* The IntuiText structure: */
  64. struct IntuiText gadget_text=
  65. {
  66.   1,         /* FrontPen, colour register 1. */
  67.   0,         /* BackPen, colour register 0. */
  68.   JAM1,      /* DrawMode, draw the characters with colour 1, do not */
  69.              /* change the background. */ 
  70.   4, 2,      /* LeftEdge, TopEdge. */
  71.   NULL,      /* ITextFont, use default font. */
  72.   "PRESS ME",/* IText, the text that will be printed. */
  73.   NULL,      /* NextText, no other IntuiText structures are connected. */
  74. };
  75.  
  76. struct Gadget requester_gadget=
  77. {
  78.   NULL,          /* NextGadget, no more gadgets in the list. */
  79.   40,            /* LeftEdge, 40 pixels out. */
  80.   20,            /* TopEdge, 20 lines down. */
  81.   71,            /* Width, 71 pixels wide. */
  82.   11,            /* Height, 11 pixels lines heigh. */
  83.   GADGHCOMP,     /* Flags, when this gadget is highlighted, the gadget */
  84.                  /* will be rendered in the complement colours. */
  85.                  /* (Colour 0 (00) will be changed to colour 3 (11) */
  86.                  /* (Colour 1 (01)           - " -           2 (10) */
  87.                  /* (Colour 2 (10)           - " -           1 (01) */
  88.                  /* (Colour 3 (11)           - " -           0 (00) */  
  89.   GADGIMMEDIATE| /* Activation, our program will recieve a message when */
  90.   RELVERIFY|     /* the user has selected this gadget, and when the user */
  91.                  /* has released it. */
  92.   ENDGADGET,     /* When the user has selected this gadget, the */
  93.                  /* requester is satisfied, and is deactivated. */
  94.                  /* IMPORTANT! At least one gadget per requester */
  95.                  /* must have the flag ENDGADGET set. If not, the */
  96.                  /* requester would never be deactivated! */
  97.  
  98.   BOOLGADGET|    /* GadgetType, a Boolean gadget which is connected to */
  99.   REQGADGET,     /* a requester. IMPORTANT! Every gadget which is */
  100.                  /* connectd to a requester must have the REQGADGET flsg */
  101.                  /* set in the GadgetType field. */
  102.   (APTR) &gadget_border, /* GadgetRender, a pointer to our Border struc. */
  103.   NULL,          /* SelectRender, NULL since we do not supply the gadget */
  104.                  /* with an alternative image. (We complement the */
  105.                  /* colours instead) */
  106.   &gadget_text,  /* GadgetText, a pointer to our IntuiText structure. */
  107.                  /* (See chapter 3 GRAPHICS for more information) */
  108.   NULL,          /* MutualExclude, no mutual exclude. */
  109.   NULL,          /* SpecialInfo, NULL since this is a Boolean gadget. */
  110.                  /* (It is not a Proportional/String or Integer gdget) */
  111.   0,             /* GadgetID, no id. */
  112.   NULL           /* UserData, no user data connected to the gadget. */
  113. };
  114.  
  115. /***********************************************************************/
  116. /* Important notice:                                                   */
  117. /* Remember that every gadget which is connected to a requester must   */
  118. /* have the flag REQGADGET set in the GadgetType field. Remember also  */
  119. /* that at least one gadget per requester must have the ENDGADGET flag */
  120. /* set in the Activation field.                                        */
  121. /***********************************************************************/
  122.  
  123.  
  124.  
  125. /************************************/
  126. /* THE BORDER AROUND THE REQUESTER: */
  127. /************************************/
  128.  
  129. /* The coordinates for the box around the requester: */
  130. SHORT requester_border_points[]=
  131. {
  132.     0,  0, /* Start at position (0,0) */
  133.   319,  0, /* Draw a line to the right to position (319,0) */
  134.   319, 99, /* Draw a line down to position (319,99) */
  135.     0, 99, /* Draw a line to the right to position (319,99) */
  136.     0,  0  /* Finish of by drawing a line up to position (0,0) */ 
  137. };
  138.  
  139. /* The Border structure for the requester: */
  140. struct Border requester_border=
  141. {
  142.   0, 0,        /* LeftEdge, TopEdge. */
  143.   1,           /* FrontPen, colour register 1. */
  144.   0,           /* BackPen, for the moment unused. */
  145.   JAM1,        /* DrawMode, draw the lines with colour 1. */
  146.   5,           /* Count, 5 pair of coordinates in the array. */
  147.   requester_border_points, /* XY, pointer to the array with the coord. */
  148.   NULL,        /* NextBorder, no other Border structures are connected. */
  149. };
  150.  
  151.  
  152.  
  153. /**********************************/
  154. /* THE TEXT INSIDE THE REQUESTER: */
  155. /**********************************/
  156.  
  157. /* The IntuiText structure used to print some text inside the requester: */
  158. struct IntuiText requester_text=
  159. {
  160.   1,         /* FrontPen, colour register 1. */
  161.   0,         /* BackPen, unused since JAM1. */
  162.   JAM1,      /* DrawMode, draw the characters with colour 1, do not */
  163.              /* change the background. */ 
  164.   4, 2,      /* LeftEdge, TopEdge. */
  165.   NULL,      /* ITextFont, use default font. */
  166.   "This is the requester!", /* IText, the text that will be printed. */
  167.   NULL,      /* NextText, no other IntuiText structures are connected. */
  168. };
  169.  
  170.  
  171.  
  172. /* Note:                                                                */
  173. /* This is the structure for the Double-menu requester, but as you have */
  174. /* maybe noticed, it is exactly the same as a normal requester struc.   */
  175. /* The diffrence is that we call the function SetDMRequest() instead    */
  176. /* of calling the function Request().                                   */
  177.  
  178. struct Requester my_requester=
  179. {
  180.   NULL,              /* OlderRequester, used by Intuition. */
  181.   40, 20,            /* LeftEdge, TopEdge, 40 pixels out, 20 lines down. */
  182.   320, 100,          /* Width, Height, 320 pixels wide, 100 lines high. */
  183.   0, 0,              /* RelLeft, RelTop, Since POINTREL flag is not set, */
  184.                      /* Intuition ignores