-- $Date: 2004/01/02 04:40:02 $
-- $Revision: 1.25 $
-- $Author: jcrocholl $

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

with Render_Glyphs; use Render_Glyphs;

package body Glyphs is

   -- Constructor for instances.
   function Create
     (Name : in String-- The initial name.
     return Glyph       -- The newly created glyph.
   is
      Result : Glyph := new Glyph_Record;
   begin
      Result.Name := To_Unbounded_String(Name);
      return Result;
   end Create;

   -- Accessor to read the name of a glyph.
   function Get_Name
     (This : in Glyph-- The glyph to read from.
     return String is  -- The name of that glyph.
   begin
      return To_String(This.Name);
   end Get_Name;

   -- Accessor to read the bounds of a glyph.
   function Get_Bounds
     (This : in Glyph-- The glyph to read from.
     return Box is     -- The bounds of that glyph.
   begin
      return This.Bounds;
   end Get_Bounds;

   -- Accessor to read the outlines of a glyph.
   function Get_Outlines
     (This : in Glyph)      -- The glyph to read from.
     return Outline_List is -- The outlines of that glyph.
   begin
      return This.Outlines;
   end Get_Outlines;

   -- Add an outline to a glyph.
   procedure Add_Outline
     (This : in Glyph;      -- The glyph object instance.
      Add  : in Outline) is -- Add this outline to the glyph.
   begin
      Outline_Lists.Push(This.Outlines, Add);
   end Add_Outline;

   -- Get a raster image of this glyph. Create one if not cached.
   function Get_Image
     (This         : in Glyph;    -- The glyph object instance.
      Staff_Height : in Real;     -- Height of staff in pixels.
      Aspect_Ratio : in Real;     -- Zoom factor for X resolution.
      Anti_Alias   : in Positive-- Factor for vertical anti-alias.
     return Glyph_Image is        -- The image of the glyph.
   begin
      if This.Image = null
        or else This.Image.Zoom /= Staff_Height
        or else This.Image.Aspect_Ratio /= Aspect_Ratio
        or else This.Image.Anti_Alias /= Anti_Alias
      then
         This.Image := Render(This, Staff_Height, Aspect_Ratio, Anti_Alias);
      end if;
      return This.Image;
   end Get_Image;

   -- Update the bounding box of the glyph.
   procedure Set_Bounds
     (This         : in Glyph;   -- The glyph object instance.
      Left, Bottom : in Real;    -- Coordinate minima.
      Right, Top   : in Real) is -- Coordinate maxima.
   begin
      This.Bounds := Box'(Left, Bottom, Right, Top);
   end Set_Bounds;

   -- Calculate the width of this glyph's bounding box.
   function Get_Width
     (This : in Glyph-- The glyph object instance.
     return Real is    -- The width of the glyph.
   begin
      return Get_Width(This.Bounds);
   end Get_Width;

   -- Calculate the height of this glyph's bounding box.
   function Get_Height
     (This : in Glyph-- The glyph object instance.
     return Real is    -- The height of the glyph.
   begin
      return Get_Height(This.Bounds);
   end Get_Height;

end Glyphs;