home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / cmanual-3.0.lha / CManual / Intuition / Requesters / Example10.c < prev    next >
C/C++ Source or Header  |  1993-10-12  |  17KB  |  470 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:    Example10.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 example demonstrates how you use a requester with a */
  21. /* predrawn bitmap. This is very useful when you want       */
  22. /* colourful and eye catching requesters. The advantage     */
  23. /* with a special bitmap is that if the window which the    */
  24. /* requester is tied to is resized, the drawing will not be */
  25. /* destroied.                                               */
  26. /*                                                          */
  27. /* The graphics data is stored in a separate file called    */
  28. /* "Example10Graphics.c". Both this and the graphical file  */
  29. /* should be compiled separately, then linked together. If  */
  30. /* you have a SAS (Lattice) C Compiler you would do like    */
  31. /* this:                                                    */
  32. /*   lc Example10.c                                         */
  33. /*   lc Example10Graphics.c                                 */
  34. /*   blink with Example10.lnk                               */ 
  35. /*                                                          */
  36. /* This program will NOT try to erase the disk! It is ony a */
  37. /* demonstration how to use a requester.                    */
  38.  
  39.  
  40.  
  41. #include <intuition/intuition.h>
  42.  
  43.  
  44.  
  45. /* The size of the requester: */
  46. #define WIDTH      310
  47. #define HEIGHT     180
  48. #define DEPTH        4
  49. #define COLOURS     16
  50.  
  51.  
  52.  
  53. struct IntuitionBase *IntuitionBase;
  54. struct GfxBase *GfxBase;
  55.  
  56.  
  57.  
  58.  
  59. /* The graphics for the requester: */
  60. extern UWORD chip YesNoData[];
  61.  
  62. /* The sixteen colours: (RGB) */
  63. UWORD colour[COLOURS]=
  64. {
  65.   0x000, 0xFFF, 0x500, 0x900, 0xE00, 0xE60, 0xFE0, 0x06F,
  66.   0x0AF, 0x04C, 0x666, 0x888, 0xBBB, 0x555, 0x028, 0x0CF
  67. };
  68.  
  69. /* The YesNo image structure: */
  70. struct Image YesNoImage=
  71. {
  72.   0, 0,            /* LeftEdge, TopEdge */
  73.   285, 154, DEPTH, /* Width, Height, Depth */
  74.   YesNoData,       /* ImageData */
  75.   0x0F, 0x00,      /* PlanePick, PlaneOnOff */
  76.   NULL             /* NextImage */
  77. };
  78.  
  79. /* The BitMap structure: */
  80. struct BitMap my_bitmap;
  81.  
  82. /* The RastPort: */
  83. struct RastPort my_rast_port;
  84.  
  85.  
  86.  
  87. /* The YES gadget (the left one): */
  88. struct Gadget yes_gadget=
  89. {
  90.   NULL,          /* NextGadget, no more gadgets in the list. */
  91.   44,            /* LeftEdge, 44 pixels out. */
  92.   108,           /* TopEdge, 108 lines down. */
  93.   80,            /* Width, 80 pixels wide. */
  94.   30,            /* Height, 30 pixels lines heigh. */
  95.   GADGHCOMP,     /* Flags, when this gadget is highlighted, the gadget */
  96.                  /* will be rendered in the complement colours. */
  97.   GADGIMMEDIATE| /* Activation, our program will recieve a message when */
  98.   RELVERIFY|     /* the user has selected this gadget, and when the user */
  99.                  /* has released it. */
  100.   ENDGADGET,     /* When the user has selected this gadget, the */
  101.                  /* requester is satisfied, and is deactivated. */
  102.                  /* IMPORTANT! At least one gadget per requester */
  103.                  /* must have the flag ENDGADGET set. If not, the */
  104.                  /* requester would never be deactivated! */
  105.  
  106.   BOOLGADGET|    /* GadgetType, a Boolean gadget which is connected to */
  107.   REQGADGET,     /* a requester. IMPORTANT! Every gadget which is */
  108.                  /* connectd to a requester must have the REQGADGET flsg */
  109.                  /* set in the GadgetType field. */
  110.   NULL,          /* GadgetRender, no rendering. */
  111.   NULL,          /* SelectRender, no alternative rendering. */
  112.   NULL,          /* GadgetText, no text. */
  113.   NULL,          /* MutualExclude, no mutual exclude. */
  114.   NULL,          /* SpecialInfo, NULL since this is a Boolean gadget. */
  115.                  /* (It is not a Proportional/String or Integer gdget) */
  116.   0,             /* GadgetID, no id. */
  117.   NULL           /* UserData, no user data connected to the gadget. */
  118. };
  119.  
  120. /* The NO gadget (the right one): */
  121. struct Gadget no_gadget=
  122. {
  123.   &yes_gadget,   /* NextGadget, pointer to the yes gadget. */
  124.   200,           /* LeftEdge, 200 pixels out. */
  125.   108,           /* TopEdge, 108 lines down. */
  126.   75,            /* Width, 75 pixels wide. */
  127.   30,            /* Height, 30 pixels lines heigh. */
  128.   GADGHCOMP,     /* Flags, when this gadget is highlighted, the gadget */
  129.                  /* will be rendered in the complement colours. */
  130.   GADGIMMEDIATE| /* Activation, our program will recieve a message when */
  131.   RELVERIFY,     /* the user has selected this gadget, and when the user */
  132.                  /* has released it. */
  133.   BOOLGADGET|    /* GadgetType, a Boolean gadget which is connected to */
  134.   REQGADGET,     /* a requester. IMPORTANT! Every gadget which is */
  135.                  /* connectd to a requester must have the REQGADGET flsg */
  136.                  /* set in the GadgetType field. */
  137.   NULL,          /* GadgetRender, no rendering. */
  138.   NULL,          /* SelectRender, no alternative rendering. */
  139.   NULL,          /* GadgetText, no text. */
  140.   NULL,          /* MutualExclude, no mutual exclude. */
  141.   NULL,          /* SpecialInfo, NULL since this is a Boolean gadget. */
  142.                  /* (It is not a Proportional/String or Integer gdget) */
  143.   0,             /* GadgetID, no id. */
  144.   NULL           /* UserData, no user data connected to the gadget. */
  145. };
  146.  
  147. /***********************************************************************/
  148. /* Important notice:                                                   */
  149. /* Remember that every gadget which is connected to a requester must   */
  150. /* have the flag REQGADGET set in the GadgetType field. Remember also  */
  151. /* that at least one gadget per requester must have the ENDGADGET flag */
  152. /* set in the Activation field.                                        */
  153. /***********************************************************************/
  154.  
  155.  
  156.  
  157. /* The request structure: */
  158. struct Requester my_requester=
  159. {
  160.   NULL,              /* OlderRequester, used by Intuition. */
  161.   5, 15,             /* LeftEdge, TopEdge, 0 pixels out, 0 lines down. */
  162.   WIDTH, HEIGHT,     /* Width, Height, 285 pixels wide, 154 lines high. */
  163.   0, 0,              /* RelLeft, RelTop, Since POINTREL flag is not set, */
  164.                      /* Intuition ignores these values. */
  165.   &no_gadget,        /* ReqGadget, pointer to the first gadget. */
  166.   NULL,              /* ReqBorder, no rendering. */
  167.   NULL,              /* ReqText, no text. */
  168.   PREDRAWN,          /* Flags, we use our own predrawn BitMap. */
  169.   0,                 /* BackFill, no backfill. */
  170.   NULL,              /* ReqLayer, used by Intuition. Set to NULL. */
  171.   NULL,              /* ReqPad1, used by Intuition. Set to NULL. */
  172.   NULL,              /* ImageBMap, will later be changed. */
  173.   NULL,              /* RWindow, used by Intuition. Set to NULL. */
  174.   NULL               /* ReqPad2, used by Intuition. Set to NULL. */
  175. };
  176.  
  177.  
  178.  
  179.  
  180. /* A pinter to a Screen structure: */ 
  181. struct Screen *my_screen;
  182.  
  183. /* The NewScreen structure: */
  184. struct NewScreen my_new_screen=
  185. {
  186.   0,            /* LeftEdge  Should always be 0. */
  187.   0,            /* TopEdge   Top of the display.*/
  188.   320,          /* Width     We are using a high-resolution screen. */
  189.   200,          /* Height    Non-Interlaced NTSC (American) display. */
  190.   DEPTH,