(*************************************************************************

     $RCSfile: Gadgets.mod $
  Description: Interface to the colorwheel, tapedeck and gradientslider
               gadgets.

   Created by: fjc (Frank Copeland)
    $Revision: 3.1 $
      $Author: fjc $
        $Date: 1994/08/08 01:16:55 $

  Includes Release 40.15

  (C) Copyright 1992-1993 Commodore-Amiga Inc.
      All Rights Reserved

  Oberon-A Interface Copyright © 1994, Frank Copeland.
  This file is part of the Oberon-A Interface.
  See Oberon-A.doc for conditions of use and distribution.

*************************************************************************)

MODULE Gadgets;

(*
** $C- CaseChk       $I- IndexChk  $L+ LongAdr   $N- NilChk
** $P- PortableCode  $R- RangeChk  $S- StackChk  $T- TypeChk
** $V- OvflChk       $Z- ZeroVars
*)

IMPORT
  E   := Exec,
  U   := Utility,
  SYS := SYSTEM;

(*
**      $VER: gradientslider.h 39.1 (18.6.92)
**
**      Definitions for the gradientslider BOOPSI class
*)

(************************************************************************)

CONST

  gradDummy *      = U.tagUser + 005000000H;
  gradMaxVal *     = gradDummy+1;  (* max value of slider         *)
  gradCurVal *     = gradDummy+2;  (* current value of slider     *)
  gradSkipVal *    = gradDummy+3;  (* "body click" move amount    *)
  gradKnobPixels * = gradDummy+4;  (* size of knob in pixels      *)
  gradPenArray *   = gradDummy+5;  (* pen colors                  *)


(************************************************************************)

(*
**      $VER: tapedeck.h 40.0 (12.3.93)
**
**      Definitions for the tapedeck BOOPSI class
*)

(************************************************************************)

CONST

  tdeckDummy *     = U.tagUser + 005000000H;
  tdeckMode *      = tdeckDummy + 1;
  tdeckPaused *    = tdeckDummy + 2;

  tdeckTape *      = tdeckDummy + 3;
    (* (BOOL) Indicate whether tapedeck or animation controls.  Defaults
     * to FALSE. *)

  tdeckFrames *    = tdeckDummy + 11;
    (* (LONG) Number of frames in animation.  Only valid when using
     * animation controls. *)

  tdeckCurrentframe * = tdeckDummy + 12;
    (* (LONG) Current frame.  Only valid when using animation controls. *)

(************************************************************************)

CONST

(* Possible values for tdeckMode *)
  butRewind *  = 0;
  butPlay *    = 1;
  butForward * = 2;
  butStop *    = 3;
  butPause *   = 4;
  butBegin *   = 5;
  butFrame *   = 6;
  butEnd *     = 7;

(***********************************************************************)

(*
**      $VER: colorwheel.h 39.2 (22.6.92)
**
**      Definitions for the colorwheel BOOPSI class
*)

(***********************************************************************)

TYPE

(* For use with the WHEEL_HSB tag *)
  ColorWheelHSBPtr * = CPOINTER TO ColorWheelHSB;
  ColorWheelHSB * = RECORD
    hue * : E.ULONG;
    saturation * : E.ULONG;
    brightness * : E.ULONG;
  END;

(* For use with the WHEEL_RGB tag *)
  ColorWheelRGBPtr * = CPOINTER TO ColorWheelRGB;
  ColorWheelRGB * = RECORD
    red * : E.ULONG;
    green * : E.ULONG;
    blue * : E.ULONG;
  END;


(***********************************************************************)

CONST

  wheelDummy *          = U.tagUser + 004000000H;
  wheelHue *            = wheelDummy+1;  (* set/get Hue               *)
  wheelSaturation *     = wheelDummy+2;  (* set/get Saturation        *)
  wheelBrightness *     = wheelDummy+3;  (* set/get Brightness        *)
  wheelHSB *            = wheelDummy+4;  (* set/get ColorWheelHSB     *)
  wheelRed *            = wheelDummy+5;  (* set/get Red               *)
  wheelGreen *          = wheelDummy+6;  (* set/get Green             *)
  wheelBlue *           = wheelDummy+7;  (* set/get Blue              *)
  wheelRGB *            = wheelDummy+8;  (* set/get ColorWheelRGB     *)
  wheelScreen *         = wheelDummy+9;  (* init screen/enviroment    *)
  wheelAbbrv *          = wheelDummy+10; (* "GCBMRY" if English       *)
  wheelDonation *       = wheelDummy+11; (* colors donated by app     *)
  wheelBevelBox *       = wheelDummy+12; (* inside a bevel box        *)
  wheelGradientSlider * = wheelDummy+13; (* attached gradient slider  *)
  wheelMaxPens *        = wheelDummy+14; (* max # of pens to allocate *)


(*-- Library Base variable --------------------------------------------*)

CONST

  colorwheelName * = "colorwheel.library";

TYPE

  ColorWheelBasePtr* = CPOINTER TO ColorWheelBase;
  ColorWheelBase* = RECORD (E.Library) END;

VAR

  base* : ColorWheelBasePtr;


(*-- Library Functions ------------------------------------------------*)

(*
**      $VER: colorwheel_protos.h 39.1 (21.7.92)
*)

(*--- functions in V39 or higher (Release 3) ---*)

(* Public entries *)

LIBCALL (base : ColorWheelBasePtr) ConvertHSBToRGB *
  ( hsb [8] : ColorWheelHSBPtr;
    rgb [9] : ColorWheelRGBPtr );
  -30;

LIBCALL (base : ColorWheelBasePtr) ConvertRGBToHSB *
  ( rgb [8] : ColorWheelRGBPtr;
    hsb [9] : ColorWheelHSBPtr );
  -36;

(*-- Library Base variable --------------------------------------------*)

(*-----------------------------------*)
PROCEDURE* CloseColorWheel ();

BEGIN (* CloseColorWheel *)
  IF base # NIL THEN E.base.CloseLibrary (base) END
END CloseColorWheel;

(*-----------------------------------*)
PROCEDURE OpenColorWheel * (mustOpen : BOOLEAN);

BEGIN (* OpenColorWheel *)
  IF base = NIL THEN
    base :=
      SYS.VAL (
        ColorWheelBasePtr,
        E.base.OpenLibrary (colorwheelName, E.libraryMinimum));
    IF base # NIL THEN SYS.SETCLEANUP (CloseColorWheel)
    ELSIF mustOpen THEN HALT (100)
    END;
  END;
END OpenColorWheel;

BEGIN
  base := NIL
END Gadgets.
