home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / cmanual-3.0.lha / CManual / Intuition / Requesters / Example8.c < prev    next >
C/C++ Source or Header  |  1993-10-12  |  24KB  |  593 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:    Example8.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 an Integer gadget.                             */
  26.  
  27.  
  28.  
  29. #include <intuition/intuition.h>
  30.  
  31.  
  32.  
  33. struct IntuitionBase *IntuitionBase;
  34.  
  35.  
  36.  
  37. /************************************/
  38. /* THE INTEGER GADGET's STRUCTURES: */
  39. /************************************/
  40.  
  41. /* The coordinates for the box around the integer gadget: */
  42. SHORT integer_border_points[]=
  43. {
  44.    -7, -4, /* Start at position (-7, -4) */
  45.   200, -4, /* Draw a line to the right to position (200,-4) */
  46.   200, 11, /* Draw a line down to position (200,11) */
  47.    -7, 11, /* Draw a line to the left to position (-7,11) */
  48.    -7, -4  /* Finish of by drawing a line up to position (-7,-4) */ 
  49. };
  50.  
  51. /* The Border structure for the integer gadget: */
  52. struct Border integer_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.   integer_border_points,/* XY, pointer to the array with the coordinates. */
  60.   NULL,                 /* NextBorder, no other Border structures. */
  61. };
  62.  
  63.  
  64.  
  65. /* The IntuiText structure for the integer gadget: */
  66. struct IntuiText integer_text=
  67. {
  68.   1,         /* FrontPen, colour register 1. (white) */
  69.   0,         /* BackPen, not used since JAM1. */
  70.   JAM1,      /* DrawMode, draw the characters with colour 1, and do not */
  71.              /* bother about the background. */ 
  72.   -53, 0,    /* LeftEdge, TopEdge. */
  73.   NULL,      /* ITextFont, use default font. */
  74.   "Age: ",   /* IText, the text that will be printed. */
  75.   NULL,      /* NextText, no other IntuiText structures. */
  76. };
  77.  
  78.  
  79.  
  80. UBYTE my_buffer[25]; /* 25 characters including the NULL-sign. */
  81. UBYTE my_undo_buffer[25]; /* Must be at least as big as my_buffer. */
  82.  
  83.  
  84.  
  85. struct StringInfo integer_info=
  86. {
  87.   my_buffer,       /* Buffer, pointer to a null-terminated string. */
  88.   my_undo_buffer,  /* UndoBuffer, pointer to a null-terminated string. */
  89.                    /* (Remember my_buffer is equal to &my_buffer[0]) */
  90.   0,               /* BufferPos, initial position of the cursor. */
  91.   25,              /* MaxChars, 25 characters inc. null-sign ('\0'). */
  92.   0,               /* DispPos, first character in the string should be */
  93.                    /* first character in the display. */
  94.  
  95.   /* Intuition initializes and maintaines these variables: */
  96.  
  97.   0,               /* UndoPos */
  98.   0,               /* NumChars */
  99.   0,               /* DispCount */
  100.   0, 0,            /* CLeft, CTop */
  101.   NULL,            /* LayerPtr */
  102.   NULL,            /* LongInt */
  103.   NULL,            /* AltKeyMap */
  104. };
  105.  
  106.  
  107. struct Gadget integer_gadget=
  108. {
  109.   NULL,          /* NextGadget, no more gadgets in the list. */
  110.   68,            /* LeftEdge, 68 pixels out. */
  111.   26,            /* TopEdge, 26 lines down. */
  112.   198,           /* Width, 198 pixels wide. */
  113.   8,             /* Height, 8 pixels lines heigh. */
  114.   GADGHCOMP,     /* Flags, draw the select box in the complement */
  115.                  /* colours. Note: it actually only the cursor which */
  116.                  /* will be drawn in the complement colours (yellow). */
  117.                  /* If you set the flag GADGHNONE the cursor will not be */
  118.                  /* highlighted, and the user will therefore not be able */
  119.                  /* to see it. */
  120.   GADGIMMEDIATE| /* Activation, our program will recieve a message when */
  121.   RELVERIFY|     /* the user has selected this gadget, and when the user */
  122.                  /* has released it. */ 
  123.   LONGINT,       /* An Integer gadget. */
  124.   STRGADGET|     /* GadgetType, a String gadget which is connected to */
  125.   REQGADGET,     /* a requester. IMPORTANT! Every gadget which is */
  126.                  /* connectd to a requester must have the REQGADGET flsg */
  127.                  /* set in the GadgetType field. */
  128.   (APTR) &integer_border, /* GadgetRender, a pointer to our Border struc. */
  129.   NULL,          /* SelectRender, NULL since we do not supply the gadget */
  130.                  /* with an alternative image. */
  131.   &integer_text,  /* GadgetText, a pointer to our IntuiText structure. */
  132.   NULL,          /* MutualExclude, no mutual exclude. */
  133.   (APTR) &integer_info, /* SpecialInfo, a pointer to a StringInfo str. */
  134.   0,             /* GadgetID, no id. */
  135.   NULL           /* UserData, no user data connected to the gadget. */
  136. };
  137.  
  138.  
  139.  
  140. /*******************************/
  141. /* THE OK GADGET's STRUCTURES: */
  142. /*******************************/
  143.  
  144. /* The coordinates for the OK box: */
  145. SHORT ok_border_points[]=
  146. {
  147.    0,  0, /* Start at position (0,0) */
  148.   22,  0, /* Draw a line to the right to position (22,0) */
  149.   22, 10, /* Draw a line down to position (22,10) */
  150.    0, 10, /* Draw a line to the left to position (0,10) */
  151.    0,  0  /* Finish of by drawing a line up to position (0,0) */ 
  152. };
  153.  
  154. /* The Border structure: */
  155. struct Border ok_border=
  156. {
  157.   0, 0,        /* LeftEdge, TopEdge. */
  158.   1,           /* FrontPen, colour register 1. */
  159.   0,           /* BackPen, for the moment unused. */
  160.   JAM1,        /* DrawMode, draw the lines with colour 1. */
  161.   5,           /* Count, 5 pair of coordinates in the array. */
  162.   ok_border_points, /* XY, pointer to the array with the coord. */
  163.   NULL,        /* NextBorder, no other Border structures are connected. */
  164. };
  165.  
  166. /* The IntuiText structure: */
  167. struct IntuiText ok_text=
  168. {
  169.   1,      /* FrontPen, colour register 1. */
  170.   0,      /* BackPen, not used since JAM1. */
  171.   JAM1,   /* DrawMode, draw the characters with colour 1, do not */
  172.           /* change the background. */ 
  173.   4, 2,   /* LeftEdge, TopEdge. */
  174.   NULL,   /* ITextFont, use default font. */
  175.   "OK",   /* IText, the text that will be printed. */
  176.   NULL,   /* NextText, no other IntuiText structures are connected. */
  177. };
  178.  
  179. struct Gadget ok_gadget=
  180. {
  181.   &integer_gadget, /* NextGadget, linked to the Integer gadget. */
  182.   14,            /* LeftEdge, 14 pixels out. */
  183.   47,            /* TopEdge, 47 lines down. */
  184.   23,            /* Width, 23 pixels wide. */
  185.   11,            /* Height, 11 pixels lines heigh. */
  186.   GADGHCOMP,     /* Flags, when this gadget is highlighted, the gadget */
  187.                  /* will be rendered in the complement colours. */
  188.                  /* (Colour 0 (00) will be changed to colour 3 (11) */
  189.                  /* (Colour 1 (01)           - " -           2 (10) */
  190.                  /* (Colour 2 (10)           - " -           1 (01) */
  191.                  /* (Colour 3 (11)           - " -           0 (00) */  
  192.   GADGIMMEDIATE| /* Activation, our program will recieve a message when */
  193.   RELVERIFY|     /* the user has selected this gadget, and when the user */
  194.                  /* h