with GNATCOM.IInterface;

with GNATCOM.Errors;

package body MSHTML.IDOMEvent_Interface is

   procedure Initialize (This : in out IDOMEvent_Type) is
   begin
      Set_IID (This, IID_IDOMEvent);
   end Initialize;

   function Pointer (This : IDOMEvent_Type)
     return Pointer_To_IDOMEvent
   is
   begin
      return To_Pointer_To_IDOMEvent (Address (This));
   end Pointer;

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

   function Get_bubbles
     (This : IDOMEvent_Type)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_bubbles
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_bubbles;

   function Get_cancelable
     (This : IDOMEvent_Type)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_cancelable
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_cancelable;

   function Get_currentTarget
     (This : IDOMEvent_Type)
     return Pointer_To_IEventTarget
   is
       RetVal : aliased Pointer_To_IEventTarget;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_currentTarget
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_currentTarget;

   function Get_defaultPrevented
     (This : IDOMEvent_Type)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_defaultPrevented
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_defaultPrevented;

   function Get_eventPhase
     (This : IDOMEvent_Type)
     return Interfaces.C.unsigned_short
   is
       RetVal : aliased Interfaces.C.unsigned_short;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_eventPhase
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_eventPhase;

   function Get_target
     (This : IDOMEvent_Type)
     return Pointer_To_IEventTarget
   is
       RetVal : aliased Pointer_To_IEventTarget;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_target
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_target;

   function Get_timeStamp
     (This : IDOMEvent_Type)
     return GNATCOM.Types.DWORDLONG
   is
       RetVal : aliased GNATCOM.Types.DWORDLONG;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_timeStamp
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_timeStamp;

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

      return RetVal;
   end Get_type;

   procedure initEvent
     (This       : IDOMEvent_Type;
      eventType  : GNATCOM.Types.BSTR;
      canBubble  : GNATCOM.Types.VARIANT_BOOL;
      cancelable : GNATCOM.Types.VARIANT_BOOL;
      Free       : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.initEvent
         (Pointer (This),
          eventType,
          canBubble,
          cancelable));

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

   end initEvent;

   procedure preventDefault
     (This : IDOMEvent_Type)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.preventDefault
         (Pointer (This)));

   end preventDefault;

   procedure stopPropagation
     (This : IDOMEvent_Type)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.stopPropagation
         (Pointer (This)));

   end stopPropagation;

   procedure stopImmediatePropagation
     (This : IDOMEvent_Type)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.stopImmediatePropagation
         (Pointer (This)));

   end stopImmediatePropagation;

   function Get_isTrusted
     (This : IDOMEvent_Type)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_isTrusted
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_isTrusted;

   procedure Put_cancelBubble
     (This : IDOMEvent_Type;
      p    : GNATCOM.Types.VARIANT_BOOL)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_cancelBubble
         (Pointer (This),
          p));

   end Put_cancelBubble;

   function Get_cancelBubble
     (This : IDOMEvent_Type)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_cancelBubble
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_cancelBubble;

   function Get_srcElement
     (This : IDOMEvent_Type)
     return Pointer_To_IHTMLElement
   is
       RetVal : aliased Pointer_To_IHTMLElement;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_srcElement
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_srcElement;

end MSHTML.IDOMEvent_Interface;

