-- $Date: 2004/03/08 11:05:10 $
-- $Revision: 1.9 $
-- $Author: jcrocholl $
-- $Hash: 6a6a2da4129cdbd6ccaf9cc8cfb17b56 $

-- This file was automatically created with ado.php.
-- Manual changes will be lost when it is updated.

package body Clefs is

   -- Constructor for instances.
   function Create
     (Number : in Natural;   -- The initial number.
      Sign   : in Sign_Enum-- The initial sign.
      Line   : in Integer)   -- The initial line.
     return Clef_Access      -- The newly created clef.
   is
      Result : Clef_Access := new Clef;
   begin
      Result.Number := Number;
      Result.Sign := Sign;
      Result.Line := Line;
      return Result;
   end Create;

   -- Accessor to read the number of a clef.
   function Get_Number
     (This : access Clef-- The clef to read from.
     return Natural is    -- The number of that clef.
   begin
      return This.Number;
   end Get_Number;

   -- Accessor to read the sign of a clef.
   function Get_Sign
     (This : access Clef-- The clef to read from.
     return Sign_Enum is  -- The sign of that clef.
   begin
      return This.Sign;
   end Get_Sign;

   function Get_Middle_C
     (This : access Clef-- The clef object instance.
     return Integer is    -- Positive is up.
   begin
      case This.Sign is
      when G => return (Get_Line(This) - 3) * 2 - 4;
      when F => return (Get_Line(This) - 3) * 2 + 4;
      when C => return (Get_Line(This) - 3) * 2;
      end case;
   end Get_Middle_C;

   function Get_Line
     (This : access Clef-- The clef object instance.
     return Integer is    -- On which line to print the clef.
   begin
      if This.Line = Auto then
         case This.Sign is
         when G => return 2;
         when F => return 4;
         when C => return 3;
         end case;
      end if;

      return This.Line;
   end Get_Line;

end Clefs;