/***************************************
 *                                     *
 * Program: Prop-Image-Gadget.c        *
 * =================================== *
 *                                     *
 * Author:  Date:      Comments:       *
 * ------  ----------  ----------      *
 * Wgb     10/16/1988  for testing     *
 *                     only            *
 *                                     *
 ***************************************/


#include <exec/types.h>
#include <intuition/intuition.h>


struct IntuitionBase *IntuitionBase;
struct Screen        *FirstScreen;
struct Window        *FirstWindow;
struct IntuiMessage  *message;


USHORT KnobGraphic[] =
   {
   0xCCCC,
   0x6666,
   0x3333,
   0x9999,
   0xCCCC,
   0x6666,
   0x3333,
   0x9999,
   0xCCCC,
   0x6666,
   0x3333,
   0x9999,
   0xCCCC,
   0x6666,
   0x3333,
   0x9999
   };

struct Image Knob =
   {
   0, 0,
   16, 16,
   1,
   &KnobGraphic[0],
   1, 0,
   NULL
   };


struct PropInfo SliderProp =
{
   FREEVERT,            /*    Flags            */
   0x8000,              /*    HorizPot         */
   0x8000,              /*    VertPot          */
   0x0800,              /*    HorizBody        */
   0x1000,              /*    VertBody         */
   0,                   /*    CWidth           */
   0,                   /*    CHeight          */
   0,                   /*    HPotRes          */
   0,                   /*    VPotRes          */
   0,                   /*    LeftBorder       */
   0                    /*    TopBorder        */
};

struct Gadget Slider =
   {
   NULL,                /* NextGadget          */
   260, 40,             /* LeftEdge, TopEdge   */
   24, 120,             /* Width, Height       */
   GADGHNONE |          /* Flags               */
   GADGIMAGE,
   RELVERIFY,           /* Activation          */
   PROPGADGET,          /* Gadget Type         */
   (APTR)&Knob,         /* GadgetRender        */
   NULL,                /* Select Render       */
   NULL,                /* GadgetText          */
   NULL,                /* MutualExclude       */
   (APTR)&SliderProp,   /* SpecialInfo         */
   1,                   /* GadgetID            */
   NULL,                /* UserData            */
   };


struct NewWindow FirstNewWindow =
   {
   160, 0,              /* LeftEdge, TopEdge   */
   320, 200,            /* Width, Height       */
   0, 1,                /* DetailPen, BlockPen */
   CLOSEWINDOW |        /* IDCMP Flags         */
   GADGETUP,
   WINDOWDEPTH |        /* Flags               */
   WINDOWSIZING |
   WINDOWDRAG |
   WINDOWCLOSE |
   SMART_REFRESH,
   &Slider,             /* First Gadget        */
   NULL,                /* CheckMark           */
   (UBYTE *)"Proportional-Gadget",
   NULL,                /* Screen              */
   NULL,                /* BitMap              */
   100, 50,             /* Min Width, Height   */
   640, 200,            /* Max Width, Height   */
   WBENCHSCREEN,        /* Type                */
   };


main()
   {
   ULONG MessageClass;
   USHORT code;
   
   struct Message *GetMsg();
   
   Open_All();
   
   FOREVER
      {
      if (message = (struct IntuiMessage *)
          GetMsg(FirstWindow->UserPort))
         {
         MessageClass = message->Class;
         code = message->Code;
         ReplyMsg(message);
         switch (MessageClass)
            {
            case CLOSEWINDOW : Close_All();
                               exit(TRUE);
                               break;
            case GADGETUP    : printf("Slider position %x\n",SliderProp.VertPot);
                               break;

            }
         }
      }
   }



Open_All()
   {
   void          *OpenLibrary();
   struct Window *OpenWindow();
   
   if (!(IntuitionBase = (struct IntuitionBase *)
       OpenLibrary("intuition.library", 0L)))
      {
      printf("Intuition Library not found!\n");
      Close_All();
      exit(FALSE);
      }
   
   if (!(FirstWindow = (struct Window *)
       OpenWindow(&FirstNewWindow)))
      {
      printf("Window will not open!\n");
      Close_All();
      exit(FALSE);
      }
   }



Close_All()
   {
   if (FirstWindow)     CloseWindow(FirstWindow);
   if (IntuitionBase)   CloseLibrary(IntuitionBase);
   }

