with GNATCOM.IInterface;

with GNATCOM.Errors;

package body MSHTML.ICanvasRenderingContext2D_Interface is

   procedure Initialize (This : in out ICanvasRenderingContext2D_Type) is
   begin
      Set_IID (This, IID_ICanvasRenderingContext2D);
   end Initialize;

   function Pointer (This : ICanvasRenderingContext2D_Type)
     return Pointer_To_ICanvasRenderingContext2D
   is
   begin
      return To_Pointer_To_ICanvasRenderingContext2D (Address (This));
   end Pointer;

   procedure Attach (This    : in out ICanvasRenderingContext2D_Type;
                     Pointer : in     Pointer_To_ICanvasRenderingContext2D)
   is
   begin
      Attach (This, GNATCOM.IInterface.To_Pointer_To_IUnknown
              (Pointer.all'Address));
   end Attach;

   function Get_canvas
     (This : ICanvasRenderingContext2D_Type)
     return Pointer_To_IHTMLCanvasElement
   is
       RetVal : aliased Pointer_To_IHTMLCanvasElement;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_canvas
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_canvas;

   procedure restore
     (This : ICanvasRenderingContext2D_Type)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.restore
         (Pointer (This)));

   end restore;

   procedure save
     (This : ICanvasRenderingContext2D_Type)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.save
         (Pointer (This)));

   end save;

   procedure rotate
     (This  : ICanvasRenderingContext2D_Type;
      angle : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.rotate
         (Pointer (This),
          angle));

   end rotate;

   procedure scale
     (This : ICanvasRenderingContext2D_Type;
      x    : Interfaces.C.C_float;
      y    : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.scale
         (Pointer (This),
          x,
          y));

   end scale;

   procedure setTransform
     (This : ICanvasRenderingContext2D_Type;
      m11  : Interfaces.C.C_float;
      m12  : Interfaces.C.C_float;
      m21  : Interfaces.C.C_float;
      m22  : Interfaces.C.C_float;
      dx   : Interfaces.C.C_float;
      dy   : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.setTransform
         (Pointer (This),
          m11,
          m12,
          m21,
          m22,
          dx,
          dy));

   end setTransform;

   procedure transform
     (This : ICanvasRenderingContext2D_Type;
      m11  : Interfaces.C.C_float;
      m12  : Interfaces.C.C_float;
      m21  : Interfaces.C.C_float;
      m22  : Interfaces.C.C_float;
      dx   : Interfaces.C.C_float;
      dy   : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.transform
         (Pointer (This),
          m11,
          m12,
          m21,
          m22,
          dx,
          dy));

   end transform;

   procedure translate
     (This : ICanvasRenderingContext2D_Type;
      x    : Interfaces.C.C_float;
      y    : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.translate
         (Pointer (This),
          x,
          y));

   end translate;

   procedure Put_globalAlpha
     (This : ICanvasRenderingContext2D_Type;
      p    : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_globalAlpha
         (Pointer (This),
          p));

   end Put_globalAlpha;

   function Get_globalAlpha
     (This : ICanvasRenderingContext2D_Type)
     return Interfaces.C.C_float
   is
       RetVal : aliased Interfaces.C.C_float;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_globalAlpha
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_globalAlpha;

   procedure Put_globalCompositeOperation
     (This : ICanvasRenderingContext2D_Type;
      p    : GNATCOM.Types.BSTR;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_globalCompositeOperation
         (Pointer (This),
          p));

      if Free then
               GNATCOM.IInterface.Free (p);
      
      end if;

   end Put_globalCompositeOperation;

   function Get_globalCompositeOperation
     (This : ICanvasRenderingContext2D_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_globalCompositeOperation
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_globalCompositeOperation;

   procedure Put_fillStyle
     (This : ICanvasRenderingContext2D_Type;
      p    : GNATCOM.Types.VARIANT;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_fillStyle
         (Pointer (This),
          p));

      if Free then
               GNATCOM.IInterface.Free (p);
      
      end if;

   end Put_fillStyle;

   function Get_fillStyle
     (This : ICanvasRenderingContext2D_Type)
     return GNATCOM.Types.VARIANT
   is
       RetVal : aliased GNATCOM.Types.VARIANT;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_fillStyle
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_fillStyle;

   procedure Put_strokeStyle
     (This : ICanvasRenderingContext2D_Type;
      p    : GNATCOM.Types.VARIANT;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_strokeStyle
         (Pointer (This),
          p));

      if Free then
               GNATCOM.IInterface.Free (p);
      
      end if;

   end Put_strokeStyle;

   function Get_strokeStyle
     (This : ICanvasRenderingContext2D_Type)
     return GNATCOM.Types.VARIANT
   is
       RetVal : aliased GNATCOM.Types.VARIANT;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_strokeStyle
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_strokeStyle;

   function createLinearGradient
     (This             : ICanvasRenderingContext2D_Type;
      x0               : Interfaces.C.C_float;
      y0               : Interfaces.C.C_float;
      x1               : Interfaces.C.C_float;
      y1               : Interfaces.C.C_float)
     return Pointer_To_ICanvasGradient
   is
       RetVal : aliased Pointer_To_ICanvasGradient;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.createLinearGradient
         (Pointer (This),
          x0,
          y0,
          x1,
          y1,
          RetVal'Unchecked_Access));

      return RetVal;
   end createLinearGradient;

   function createRadialGradient
     (This             : ICanvasRenderingContext2D_Type;
      x0               : Interfaces.C.C_float;
      y0               : Interfaces.C.C_float;
      r0               : Interfaces.C.C_float;
      x1               : Interfaces.C.C_float;
      y1               : Interfaces.C.C_float;
      r1               : Interfaces.C.C_float)
     return Pointer_To_ICanvasGradient
   is
       RetVal : aliased Pointer_To_ICanvasGradient;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.createRadialGradient
         (Pointer (This),
          x0,
          y0,
          r0,
          x1,
          y1,
          r1,
          RetVal'Unchecked_Access));

      return RetVal;
   end createRadialGradient;

   function createPattern
     (This            : ICanvasRenderingContext2D_Type;
      Image           : GNATCOM.Types.Pointer_To_IDispatch;
      repetition      : GNATCOM.Types.VARIANT;
      Free            : Boolean := True)
     return Pointer_To_ICanvasPattern
   is
       RetVal : aliased Pointer_To_ICanvasPattern;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.createPattern
         (Pointer (This),
          Image,
          repetition,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (repetition);
      
      end if;

      return RetVal;
   end createPattern;

   procedure Put_lineCap
     (This : ICanvasRenderingContext2D_Type;
      p    : GNATCOM.Types.BSTR;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_lineCap
         (Pointer (This),
          p));

      if Free then
               GNATCOM.IInterface.Free (p);
      
      end if;

   end Put_lineCap;

   function Get_lineCap
     (This : ICanvasRenderingContext2D_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_lineCap
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_lineCap;

   procedure Put_lineJoin
     (This : ICanvasRenderingContext2D_Type;
      p    : GNATCOM.Types.BSTR;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_lineJoin
         (Pointer (This),
          p));

      if Free then
               GNATCOM.IInterface.Free (p);
      
      end if;

   end Put_lineJoin;

   function Get_lineJoin
     (This : ICanvasRenderingContext2D_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_lineJoin
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_lineJoin;

   procedure Put_lineWidth
     (This : ICanvasRenderingContext2D_Type;
      p    : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_lineWidth
         (Pointer (This),
          p));

   end Put_lineWidth;

   function Get_lineWidth
     (This : ICanvasRenderingContext2D_Type)
     return Interfaces.C.C_float
   is
       RetVal : aliased Interfaces.C.C_float;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_lineWidth
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_lineWidth;

   procedure Put_miterLimit
     (This : ICanvasRenderingContext2D_Type;
      p    : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_miterLimit
         (Pointer (This),
          p));

   end Put_miterLimit;

   function Get_miterLimit
     (This : ICanvasRenderingContext2D_Type)
     return Interfaces.C.C_float
   is
       RetVal : aliased Interfaces.C.C_float;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_miterLimit
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_miterLimit;

   procedure Put_shadowBlur
     (This : ICanvasRenderingContext2D_Type;
      p    : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_shadowBlur
         (Pointer (This),
          p));

   end Put_shadowBlur;

   function Get_shadowBlur
     (This : ICanvasRenderingContext2D_Type)
     return Interfaces.C.C_float
   is
       RetVal : aliased Interfaces.C.C_float;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_shadowBlur
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_shadowBlur;

   procedure Put_shadowColor
     (This : ICanvasRenderingContext2D_Type;
      p    : GNATCOM.Types.BSTR;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_shadowColor
         (Pointer (This),
          p));

      if Free then
               GNATCOM.IInterface.Free (p);
      
      end if;

   end Put_shadowColor;

   function Get_shadowColor
     (This : ICanvasRenderingContext2D_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_shadowColor
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_shadowColor;

   procedure Put_shadowOffsetX
     (This : ICanvasRenderingContext2D_Type;
      p    : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_shadowOffsetX
         (Pointer (This),
          p));

   end Put_shadowOffsetX;

   function Get_shadowOffsetX
     (This : ICanvasRenderingContext2D_Type)
     return Interfaces.C.C_float
   is
       RetVal : aliased Interfaces.C.C_float;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_shadowOffsetX
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_shadowOffsetX;

   procedure Put_shadowOffsetY
     (This : ICanvasRenderingContext2D_Type;
      p    : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_shadowOffsetY
         (Pointer (This),
          p));

   end Put_shadowOffsetY;

   function Get_shadowOffsetY
     (This : ICanvasRenderingContext2D_Type)
     return Interfaces.C.C_float
   is
       RetVal : aliased Interfaces.C.C_float;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_shadowOffsetY
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_shadowOffsetY;

   procedure clearRect
     (This : ICanvasRenderingContext2D_Type;
      x    : Interfaces.C.C_float;
      y    : Interfaces.C.C_float;
      w    : Interfaces.C.C_float;
      h    : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.clearRect
         (Pointer (This),
          x,
          y,
          w,
          h));

   end clearRect;

   procedure fillRect
     (This : ICanvasRenderingContext2D_Type;
      x    : Interfaces.C.C_float;
      y    : Interfaces.C.C_float;
      w    : Interfaces.C.C_float;
      h    : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.fillRect
         (Pointer (This),
          x,
          y,
          w,
          h));

   end fillRect;

   procedure strokeRect
     (This : ICanvasRenderingContext2D_Type;
      x    : Interfaces.C.C_float;
      y    : Interfaces.C.C_float;
      w    : Interfaces.C.C_float;
      h    : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.strokeRect
         (Pointer (This),
          x,
          y,
          w,
          h));

   end strokeRect;

   procedure arc
     (This          : ICanvasRenderingContext2D_Type;
      x             : Interfaces.C.C_float;
      y             : Interfaces.C.C_float;
      radius        : Interfaces.C.C_float;
      startAngle    : Interfaces.C.C_float;
      endAngle      : Interfaces.C.C_float;
      anticlockwise : Interfaces.C.long)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.arc
         (Pointer (This),
          x,
          y,
          radius,
          startAngle,
          endAngle,
          anticlockwise));

   end arc;

   procedure arcTo
     (This   : ICanvasRenderingContext2D_Type;
      x1     : Interfaces.C.C_float;
      y1     : Interfaces.C.C_float;
      x2     : Interfaces.C.C_float;
      y2     : Interfaces.C.C_float;
      radius : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.arcTo
         (Pointer (This),
          x1,
          y1,
          x2,
          y2,
          radius));

   end arcTo;

   procedure beginPath
     (This : ICanvasRenderingContext2D_Type)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.beginPath
         (Pointer (This)));

   end beginPath;

   procedure bezierCurveTo
     (This : ICanvasRenderingContext2D_Type;
      cp1x : Interfaces.C.C_float;
      cp1y : Interfaces.C.C_float;
      cp2x : Interfaces.C.C_float;
      cp2y : Interfaces.C.C_float;
      x    : Interfaces.C.C_float;
      y    : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.bezierCurveTo
         (Pointer (This),
          cp1x,
          cp1y,
          cp2x,
          cp2y,
          x,
          y));

   end bezierCurveTo;

   procedure clip
     (This : ICanvasRenderingContext2D_Type)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.clip
         (Pointer (This)));

   end clip;

   procedure closePath
     (This : ICanvasRenderingContext2D_Type)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.closePath
         (Pointer (This)));

   end closePath;

   procedure fill
     (This : ICanvasRenderingContext2D_Type)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.fill
         (Pointer (This)));

   end fill;

   procedure lineTo
     (This : ICanvasRenderingContext2D_Type;
      x    : Interfaces.C.C_float;
      y    : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.lineTo
         (Pointer (This),
          x,
          y));

   end lineTo;

   procedure moveTo
     (This : ICanvasRenderingContext2D_Type;
      x    : Interfaces.C.C_float;
      y    : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.moveTo
         (Pointer (This),
          x,
          y));

   end moveTo;

   procedure quadraticCurveTo
     (This : ICanvasRenderingContext2D_Type;
      cpx  : Interfaces.C.C_float;
      cpy  : Interfaces.C.C_float;
      x    : Interfaces.C.C_float;
      y    : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.quadraticCurveTo
         (Pointer (This),
          cpx,
          cpy,
          x,
          y));

   end quadraticCurveTo;

   procedure rect
     (This : ICanvasRenderingContext2D_Type;
      x    : Interfaces.C.C_float;
      y    : Interfaces.C.C_float;
      w    : Interfaces.C.C_float;
      h    : Interfaces.C.C_float)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.rect
         (Pointer (This),
          x,
          y,
          w,
          h));

   end rect;

   procedure stroke
     (This : ICanvasRenderingContext2D_Type)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.stroke
         (Pointer (This)));

   end stroke;

   function isPointInPath
     (This    : ICanvasRenderingContext2D_Type;
      x       : Interfaces.C.C_float;
      y       : Interfaces.C.C_float)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.isPointInPath
         (Pointer (This),
          x,
          y,
          RetVal'Unchecked_Access));

      return RetVal;
   end isPointInPath;

   procedure Put_font
     (This : ICanvasRenderingContext2D_Type;
      p    : GNATCOM.Types.BSTR;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_font
         (Pointer (This),
          p));

      if Free then
               GNATCOM.IInterface.Free (p);
      
      end if;

   end Put_font;

   function Get_font
     (This : ICanvasRenderingContext2D_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_font
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_font;

   procedure Put_textAlign
     (This : ICanvasRenderingContext2D_Type;
      p    : GNATCOM.Types.BSTR;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_textAlign
         (Pointer (This),
          p));

      if Free then
               GNATCOM.IInterface.Free (p);
      
      end if;

   end Put_textAlign;

   function Get_textAlign
     (This : ICanvasRenderingContext2D_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_textAlign
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_textAlign;

   procedure Put_textBaseline
     (This : ICanvasRenderingContext2D_Type;
      p    : GNATCOM.Types.BSTR;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_textBaseline
         (Pointer (This),
          p));

      if Free then
               GNATCOM.IInterface.Free (p);
      
      end if;

   end Put_textBaseline;

   function Get_textBaseline
     (This : ICanvasRenderingContext2D_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_textBaseline
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_textBaseline;

   procedure fillText
     (This     : ICanvasRenderingContext2D_Type;
      text     : GNATCOM.Types.BSTR;
      x        : Interfaces.C.C_float;
      y        : Interfaces.C.C_float;
      maxWidth : GNATCOM.Types.VARIANT;
      Free     : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.fillText
         (Pointer (This),
          text,
          x,
          y,
          maxWidth));

      if Free then
               GNATCOM.IInterface.Free (text);
               GNATCOM.IInterface.Free (maxWidth);
      
      end if;

   end fillText;

   function measureText
     (This                : ICanvasRenderingContext2D_Type;
      text                : GNATCOM.Types.BSTR;
      Free                : Boolean := True)
     return Pointer_To_ICanvasTextMetrics
   is
       RetVal : aliased Pointer_To_ICanvasTextMetrics;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.measureText
         (Pointer (This),
          text,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (text);
      
      end if;

      return RetVal;
   end measureText;

   procedure strokeText
     (This     : ICanvasRenderingContext2D_Type;
      text     : GNATCOM.Types.BSTR;
      x        : Interfaces.C.C_float;
      y        : Interfaces.C.C_float;
      maxWidth : GNATCOM.Types.VARIANT;
      Free     : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.strokeText
         (Pointer (This),
          text,
          x,
          y,
          maxWidth));

      if Free then
               GNATCOM.IInterface.Free (text);
               GNATCOM.IInterface.Free (maxWidth);
      
      end if;

   end strokeText;

   procedure drawImage
     (This : ICanvasRenderingContext2D_Type;
      pSrc : GNATCOM.Types.Pointer_To_IDispatch;
      a1   : GNATCOM.Types.VARIANT;
      a2   : GNATCOM.Types.VARIANT;
      a3   : GNATCOM.Types.VARIANT;
      a4   : GNATCOM.Types.VARIANT;
      a5   : GNATCOM.Types.VARIANT;
      a6   : GNATCOM.Types.VARIANT;
      a7   : GNATCOM.Types.VARIANT;
      a8   : GNATCOM.Types.VARIANT;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.drawImage
         (Pointer (This),
          pSrc,
          a1,
          a2,
          a3,
          a4,
          a5,
          a6,
          a7,
          a8));

      if Free then
               GNATCOM.IInterface.Free (a1);
               GNATCOM.IInterface.Free (a2);
               GNATCOM.IInterface.Free (a3);
               GNATCOM.IInterface.Free (a4);
               GNATCOM.IInterface.Free (a5);
               GNATCOM.IInterface.Free (a6);
               GNATCOM.IInterface.Free (a7);
               GNATCOM.IInterface.Free (a8);
      
      end if;

   end drawImage;

   function createImageData
     (This              : ICanvasRenderingContext2D_Type;
      a1                : GNATCOM.Types.VARIANT;
      a2                : GNATCOM.Types.VARIANT;
      Free              : Boolean := True)
     return Pointer_To_ICanvasImageData
   is
       RetVal : aliased Pointer_To_ICanvasImageData;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.createImageData
         (Pointer (This),
          a1,
          a2,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (a1);
               GNATCOM.IInterface.Free (a2);
      
      end if;

      return RetVal;
   end createImageData;

   function getImageData
     (This              : ICanvasRenderingContext2D_Type;
      sx                : Interfaces.C.C_float;
      sy                : Interfaces.C.C_float;
      sw                : Interfaces.C.C_float;
      sh                : Interfaces.C.C_float)
     return Pointer_To_ICanvasImageData
   is
       RetVal : aliased Pointer_To_ICanvasImageData;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.getImageData
         (Pointer (This),
          sx,
          sy,
          sw,
          sh,
          RetVal'Unchecked_Access));

      return RetVal;
   end getImageData;

   procedure putImageData
     (This        : ICanvasRenderingContext2D_Type;
      imagedata   : Pointer_To_ICanvasImageData;
      dx          : Interfaces.C.C_float;
      dy          : Interfaces.C.C_float;
      dirtyX      : GNATCOM.Types.VARIANT;
      dirtyY      : GNATCOM.Types.VARIANT;
      dirtyWidth  : GNATCOM.Types.VARIANT;
      dirtyHeight : GNATCOM.Types.VARIANT;
      Free        : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.putImageData
         (Pointer (This),
          imagedata,
          dx,
          dy,
          dirtyX,
          dirtyY,
          dirtyWidth,
          dirtyHeight));

      if Free then
               GNATCOM.IInterface.Free (dirtyX);
               GNATCOM.IInterface.Free (dirtyY);
               GNATCOM.IInterface.Free (dirtyWidth);
               GNATCOM.IInterface.Free (dirtyHeight);
      
      end if;

   end putImageData;

end MSHTML.ICanvasRenderingContext2D_Interface;

