with GNATCOM.IInterface;

with GNATCOM.Errors;

package body MSHTML.IHTMLCSSMediaRule_Interface is

   procedure Initialize (This : in out IHTMLCSSMediaRule_Type) is
   begin
      Set_IID (This, IID_IHTMLCSSMediaRule);
   end Initialize;

   function Pointer (This : IHTMLCSSMediaRule_Type)
     return Pointer_To_IHTMLCSSMediaRule
   is
   begin
      return To_Pointer_To_IHTMLCSSMediaRule (Address (This));
   end Pointer;

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

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

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

   end Put_media;

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

      return RetVal;
   end Get_media;

   function Get_cssRules
     (This : IHTMLCSSMediaRule_Type)
     return Pointer_To_IHTMLStyleSheetRulesCollection
   is
       RetVal : aliased Pointer_To_IHTMLStyleSheetRulesCollection;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_cssRules
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_cssRules;

   function insertRule
     (This       : IHTMLCSSMediaRule_Type;
      bstrRule   : GNATCOM.Types.BSTR;
      lIndex     : Interfaces.C.long;
      Free       : Boolean := True)
     return Interfaces.C.long
   is
       RetVal : aliased Interfaces.C.long;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.insertRule
         (Pointer (This),
          bstrRule,
          lIndex,
          RetVal'Unchecked_Access));

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

      return RetVal;
   end insertRule;

   procedure deleteRule
     (This   : IHTMLCSSMediaRule_Type;
      lIndex : Interfaces.C.long)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.deleteRule
         (Pointer (This),
          lIndex));

   end deleteRule;

end MSHTML.IHTMLCSSMediaRule_Interface;

