home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / cmanual-3.0.lha / CManual / Intuition / Requesters / Example7.c < prev    next >
C/C++ Source or Header  |  1993-10-12  |  23KB  |  588 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:    Example7.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 String gadget.                               */
  26.  
  27.  
  28.  
  29. #include <intuition/intuition.h>
  30.  
  31.  
  32.  
  33. struct IntuitionBase *IntuitionBase;
  34.  
  35.  
  36.  
  37. /***********************************/
  38. /* THE STRING GADGET's STRUCTURES: */
  39. /***********************************/
  40.  
  41. /* The coordinates for the box around the string gadget: */
  42. SHORT string_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 string gadget: */
  52. struct Border string_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.   string_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 string gadget: */
  66. struct IntuiText string_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.   "Name:",   /* IText, the text that will be printed. */
  75.   NULL,      /* NextText, no other IntuiText structures. */
  76. };
  77.  
  78.  
  79.  
  80. UBYTE my_buffer[50]; /* 50 characters including the NULL-sign. */
  81. UBYTE my_undo_buffer[50]; /* Must be at least as big as my_buffer. */
  82.  
  83.  
  84.  
  85. struct StringInfo string_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.   50,              /* MaxChars, 50 characters + 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 string_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.   STRGADGET|     /* GadgetType, a String gadget which is connected to */
  124.   REQGADGET,     /* a requester. IMPORTANT! Every gadget which is */
  125.                  /* connectd to a requester must have the REQGADGET flsg */
  126.                  /* set in the GadgetType field. */
  127.   (APTR) &string_border, /* GadgetRender, a pointer to our Border struc. */
  128.   NULL,          /* SelectRender, NULL since we do not supply the gadget */
  129.                  /* with an alternative image. */
  130.   &string_text,  /* GadgetText, a pointer to our IntuiText structure. */
  131.   NULL,          /* MutualExclude, no mutual exclude. */
  132.   (APTR) &string_info, /* SpecialInfo, a pointer to a StringInfo str. */
  133.   0,             /* GadgetID, no id. */
  134.   NULL           /* UserData, no user data connected to the gadget. */
  135. };
  136.  
  137.  
  138.  
  139. /*******************************/
  140. /* THE OK GADGET's STRUCTURES: */
  141. /*******************************/
  142.  
  143. /* The coordinates for the OK box: */
  144. SHORT ok_border_points[]=
  145. {
  146.    0,  0, /* Start at position (0,0) */
  147.   22,  0, /* Draw a line to the right to position (22,0) */
  148.   22, 10, /* Draw a line down to position (22,10) */
  149.    0, 10, /* Draw a line to the left to position (0,10) */
  150.    0,  0  /* Finish of by drawing a line up to position (0,0) */ 
  151. };
  152.  
  153. /* The Border structure: */
  154. struct Border ok_border=
  155. {
  156.   0, 0,        /* LeftEdge, TopEdge. */
  157.   1,           /* FrontPen, colour register 1. */
  158.   0,           /* BackPen, for the moment unused. */
  159.   JAM1,        /* DrawMode, draw the lines with colour 1. */
  160.   5,           /* Count, 5 pair of coordinates in the array. */
  161.   ok_border_points, /* XY, pointer to the array with the coord. */
  162.   NULL,        /* NextBorder, no other Border structures are connected. */
  163. };
  164.  
  165. /* The IntuiText structure: */
  166. struct IntuiText ok_text=
  167. {
  168.   1,      /* FrontPen, colour register 1. */
  169.   0,      /* BackPen, not used since JAM1. */
  170.   JAM1,   /* DrawMode, draw the characters with colour 1, do not */
  171.           /* change the background. */ 
  172.   4, 2,   /* LeftEdge, TopEdge. */
  173.   NULL,   /* ITextFont, use default font. */
  174.   "OK",   /* IText, the text that will be printed. */
  175.   NULL,   /* NextText, no other IntuiText structures are connected. */
  176. };
  177.  
  178. struct Gadget ok_gadget=
  179. {
  180.   &string_gadget,/* NextGadget, linked to the string gadget. */
  181.   14,            /* LeftEdge, 14 pixels out. */
  182.   47,            /* TopEdge, 47 lines down. */
  183.   23,            /* Width, 23 pixels wide. */
  184.   11,            /* Height, 11 pixels lines heigh. */
  185.   GADGHCOMP,     /* Flags, when this gadget is highlighted, the gadget */
  186.                  /* will be rendered in the complement colours. */
  187.                  /* (Colour 0 (00) will be changed to colour 3 (11) */
  188.                  /* (Colour 1 (01)           - " -           2 (10) */
  189.                  /* (Colour 2 (10)           - " -           1 (01) */
  190.                  /* (Colour 3 (11)           - " -           0 (00) */  
  191.   GADGIMMEDIATE| /* Activation, our program will recieve a message when */
  192.   RELVERIFY|     /* the user has selected this gadget, and when the user */
  193.                  /* has released it. */
  194.   ENDGADGET,     /* When the user has selec