home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / intuitioned_377.lzh / IntuitionEd / PropGad.c < prev    next >
C/C++ Source or Header  |  1990-10-10  |  6KB  |  198 lines

  1. /*-----------------------------------------------------------
  2. --  Programm: PropGad.c
  3. --     Autor: Intuition Ed 
  4. --     Datum: Tue Apr  3
  5. --  Funktion: Example of a two-dimensions Propartionalgadget.
  6.               written by Intuition Ed
  7.               (main function changed) 
  8. ------------------------------------------------------------/*
  9.  
  10.  
  11. /*-------------------
  12. --  Include  :     --
  13. -------------------*/
  14.  
  15. #include <intuition/intuition.h>
  16.  
  17.  
  18. /*-------------------
  19. --  Define   :     --
  20. -------------------*/
  21.  
  22. #define GADGET1_GAD                              0
  23.  
  24. #define HORIZGADGET1_POS   (MAXBODY/100)
  25. #define VERTGADGET1_POS   (MAXBODY/200)
  26.  
  27. /*-------------------
  28. --  Functions   :  --
  29. -------------------*/
  30.  
  31. void                   Open_All() ;
  32. void                   Close_All();
  33.  
  34. /*-------------------
  35. --  extern         --
  36. --  Variables  :   --
  37. -------------------*/
  38.  
  39. struct IntuitionBase  *IntuitionBase;
  40. struct Window         *Window1;
  41.  
  42.  
  43. /*-------------------
  44. --  Structures  :  --
  45. -------------------*/
  46.  
  47.  
  48. struct Image    Gadget1Image;
  49. struct PropInfo Gadget1PropInfo =
  50. {
  51.  FREEHORIZ                                /* Flags                     */
  52.  | AUTOKNOB
  53.  | FREEVERT,
  54.  HORIZGADGET1_POS * 50,                   /* HorizPot                  */
  55.  VERTGADGET1_POS * 100,                   /* VertPot                   */
  56.  HORIZGADGET1_POS * 10,                   /* HorizBody                 */
  57.  VERTGADGET1_POS * 20,                    /* VertBody                  */
  58.  0,                                       /* CWidth                    */
  59.  0,                                       /* CHeight                   */
  60.  0,                                       /* HPotRes                   */
  61.  0,                                       /* VPotRes                   */
  62.  0,                                       /* LeftBorder                */
  63.  0,                                       /* TopBorder                 */
  64. };
  65.  
  66. struct Gadget Gadget1 =
  67. {
  68.  NULL,                                    /* Last Gadget               */
  69.   50, 25,                                 /* LeftEdge , TopEdge        */
  70.  100,100,                                 /* Width , Height            */
  71.  GADGHCOMP,                               /* Flags                     */
  72.  RELVERIFY,                               /* Activation                */
  73.  PROPGADGET,                              /* Gadget Type               */
  74.  (APTR)&Gadget1Image,                     /* Gadget Render             */
  75.  NULL,                                    /* No Selected Render        */
  76.  NULL,                                    /* No Gadget Text            */
  77.  NULL,                                    /* Mutual Exclude            */
  78.  (APTR)&Gadget1PropInfo,                  /* SpecialInfo               */
  79.  GADGET1_GAD,                             /* Gadget ID                 */
  80.  NULL,                                    /* User Data                 */
  81. };
  82.  
  83. /*-  NewWindow  :   ---
  84. ---  Window1        -*/
  85.  
  86. struct NewWindow NewWindow1 =
  87. {
  88.   20, 10,                                 /* LeftEdge , TopEdge        */
  89.  200,150,                                 /* Width , Height            */
  90.    0,  1,                                 /* DetailPen , BlockPen      */
  91.  GADGETDOWN                               /* IDCMP Flags               */
  92.  | GADGETUP
  93.  | CLOSEWINDOW,
  94.  WINDOWSIZING                             /* Flags                     */
  95.  | WINDOWCLOSE
  96.  | WINDOWDRAG
  97.  | WINDOWDEPTH
  98.  | SMART_REFRESH
  99.  | ACTIVATE,
  100.  &Gadget1,                                /* First Gadget              */
  101.  NULL,                                    /* Check Mark                */
  102.  NULL,                                    /* No Title                  */
  103.  NULL,                                    /* Screen                    */
  104.  NULL,                                    /* BitMap                    */
  105.   80, 30,                                 /* MinWidth , MinHeight      */
  106.  640,256,                                 /* MaxWidth , MaxHeight      */
  107.  WBENCHSCREEN,                            /* ScreenType                */
  108. };
  109.  
  110. /*-----------------------------------------------------------
  111. --  Functionname: main
  112. --   Returnvalue:  --
  113. --        Remark: Calls Open_All and Close_All .
  114. ------------------------------------------------------------*/
  115.  
  116. void main()
  117. {
  118.  struct IntuiMessage  *message;
  119.  struct Message       *GetMsg();
  120.  
  121.  Open_All();
  122.    
  123.  FOREVER
  124.  {
  125.   if (NOT(message = (struct IntuiMessage *)
  126.         GetMsg(Window1->UserPort)))
  127.   {
  128.    Wait(1L << Window1->UserPort->mp_SigBit);
  129.    continue;
  130.   }
  131.   ReplyMsg(message);
  132.  
  133.   switch (message->Class)
  134.   {
  135.    case GADGETUP    : printf(" Vert.Position: %u\n"   ,(int)(Gadget1PropInfo.VertPot/VERTGADGET1_POS));
  136.                       printf("Horiz.Position: %u\n\n",(int)(Gadget1PropInfo.HorizPot/HORIZGADGET1_POS));
  137.                       break;
  138.          
  139.    case CLOSEWINDOW : Close_All();
  140.                       exit(TRUE);
  141.          
  142.   }
  143.  }
  144. }
  145.  
  146. /*-----------------------------------------------------------
  147. --  Functionname: Open_All
  148. --          Task: Opens Intuitionlibrary,
  149. --                and structures.
  150. --  Required variables
  151. --              :  --
  152. --    Returntask:  --
  153. --        Remark: Calls Cose_All in case of trubble.
  154. ------------------------------------------------------------*/
  155.  
  156.  
  157. void Open_All()
  158. {
  159.  struct Window        *OpenWindow();
  160.  void                 *OpenLibrary();
  161.  
  162.  if (NOT(IntuitionBase = (struct IntuitionBase*)
  163.        OpenLibrary ("intuition.library", 0L)))
  164.  {
  165.   printf("No Intuition Library !!");
  166.   Close_All();
  167.   exit(FALSE);
  168.  }
  169.  
  170.  if (NOT(Window1 = (struct Window *)
  171.        OpenWindow (&NewWindow1 )))
  172.  {
  173.   printf("Window1 -  WB-Window can't be opend.\n");
  174.   Close_All();
  175.   exit(FALSE);
  176.  }
  177.  
  178. }
  179.  
  180. /*-----------------------------------------------------------
  181. --  Functionname: Close_All
  182. --          Task: Closes Intuitionlibrary
  183. --                and structures.
  184. --  Required variables
  185. --              :  --
  186. --   Returnvalue:  --
  187. --        Remark:  --
  188. ------------------------------------------------------------*/
  189.  
  190. void Close_All()
  191. {
  192.  void                  CloseWindow();
  193.  void                  CloseLibrary();
  194.  
  195.  if (Window1)   CloseWindow (Window1) ;
  196.  if (IntuitionBase)     CloseLibrary(IntuitionBase);
  197. }
  198.