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