with GNATCOM.IInterface;

with GNATCOM.Errors;

package body MSHTML.IDOMKeyboardEvent_Interface is

   procedure Initialize (This : in out IDOMKeyboardEvent_Type) is
   begin
      Set_IID (This, IID_IDOMKeyboardEvent);
   end Initialize;

   function Pointer (This : IDOMKeyboardEvent_Type)
     return Pointer_To_IDOMKeyboardEvent
   is
   begin
      return To_Pointer_To_IDOMKeyboardEvent (Address (This));
   end Pointer;

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

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

      return RetVal;
   end Get_key;

   function Get_location
     (This : IDOMKeyboardEvent_Type)
     return Interfaces.C.unsigned_long
   is
       RetVal : aliased Interfaces.C.unsigned_long;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_location
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_location;

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

      return RetVal;
   end Get_ctrlKey;

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

      return RetVal;
   end Get_shiftKey;

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

      return RetVal;
   end Get_altKey;

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

      return RetVal;
   end Get_metaKey;

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

      return RetVal;
   end Get_repeat;

   function getModifierState
     (This   : IDOMKeyboardEvent_Type;
      keyArg : GNATCOM.Types.BSTR;
      Free   : Boolean := True)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.getModifierState
         (Pointer (This),
          keyArg,
          RetVal'Unchecked_Access));

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

      return RetVal;
   end getModifierState;

   procedure initKeyboardEvent
     (This             : IDOMKeyboardEvent_Type;
      eventType        : GNATCOM.Types.BSTR;
      canBubble        : GNATCOM.Types.VARIANT_BOOL;
      cancelable       : GNATCOM.Types.VARIANT_BOOL;
      viewArg          : Pointer_To_IHTMLWindow2;
      keyArg           : GNATCOM.Types.BSTR;
      locationArg      : Interfaces.C.unsigned_long;
      modifiersListArg : GNATCOM.Types.BSTR;
      repeat           : GNATCOM.Types.VARIANT_BOOL;
      locale           : GNATCOM.Types.BSTR;
      Free             : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.initKeyboardEvent
         (Pointer (This),
          eventType,
          canBubble,
          cancelable,
          viewArg,
          keyArg,
          locationArg,
          modifiersListArg,
          repeat,
          locale));

      if Free then
               GNATCOM.IInterface.Free (eventType);
               GNATCOM.IInterface.Free (keyArg);
               GNATCOM.IInterface.Free (modifiersListArg);
               GNATCOM.IInterface.Free (locale);
      
      end if;

   end initKeyboardEvent;

   function Get_keyCode
     (This : IDOMKeyboardEvent_Type)
     return Interfaces.C.long
   is
       RetVal : aliased Interfaces.C.long;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_keyCode
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_keyCode;

   function Get_charCode
     (This : IDOMKeyboardEvent_Type)
     return Interfaces.C.long
   is
       RetVal : aliased Interfaces.C.long;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_charCode
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_charCode;

   function Get_which
     (This : IDOMKeyboardEvent_Type)
     return Interfaces.C.long
   is
       RetVal : aliased Interfaces.C.long;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_which
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_which;

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

      return RetVal;
   end Get_ie9_char;

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

      return RetVal;
   end Get_locale;

end MSHTML.IDOMKeyboardEvent_Interface;

