{-# LANGUAGE ForeignFunctionInterface, TypeFamilies, MultiParamTypeClasses, 
             FlexibleInstances, TypeSynonymInstances, EmptyDataDecls, 
             OverlappingInstances, IncoherentInstances #-}

module HROOT.Class.TBRIK.Implementation where


import HROOT.TypeCast

import HROOT.Class.TBRIK.RawType
import HROOT.Class.TBRIK.FFI
import HROOT.Class.TBRIK.Interface
import HROOT.Class.TBRIK.Cast
import HROOT.Class.TClass.RawType
import HROOT.Class.TClass.Cast
import HROOT.Class.TClass.Interface
import HROOT.Class.TShape.RawType
import HROOT.Class.TShape.Cast
import HROOT.Class.TShape.Interface
import HROOT.Class.TNamed.RawType
import HROOT.Class.TNamed.Cast
import HROOT.Class.TNamed.Interface
import HROOT.Class.TAttLine.RawType
import HROOT.Class.TAttLine.Cast
import HROOT.Class.TAttLine.Interface
import HROOT.Class.TAttFill.RawType
import HROOT.Class.TAttFill.Cast
import HROOT.Class.TAttFill.Interface
import HROOT.Class.TAtt3D.RawType
import HROOT.Class.TAtt3D.Cast
import HROOT.Class.TAtt3D.Interface
import HROOT.Class.TObject.RawType
import HROOT.Class.TObject.Cast
import HROOT.Class.TObject.Interface
import HROOT.Class.Deletable.RawType
import HROOT.Class.Deletable.Cast
import HROOT.Class.Deletable.Interface

import Data.Word
-- import Foreign.C            
-- import Foreign.Ptr
import Foreign.ForeignPtr

import System.IO.Unsafe


instance ITBRIK TBRIK where
instance ITShape TBRIK where
instance ITNamed TBRIK where
  setName = xform1 c_tbrik_setname
  setNameTitle = xform2 c_tbrik_setnametitle
  setTitle = xform1 c_tbrik_settitle
instance ITAttLine TBRIK where
  getLineColor = xform0 c_tbrik_getlinecolor
  getLineStyle = xform0 c_tbrik_getlinestyle
  getLineWidth = xform0 c_tbrik_getlinewidth
  resetAttLine = xform1 c_tbrik_resetattline
  setLineAttributes = xform0 c_tbrik_setlineattributes
  setLineColor = xform1 c_tbrik_setlinecolor
  setLineStyle = xform1 c_tbrik_setlinestyle
  setLineWidth = xform1 c_tbrik_setlinewidth
instance ITAttFill TBRIK where
  setFillColor = xform1 c_tbrik_setfillcolor
  setFillStyle = xform1 c_tbrik_setfillstyle
instance ITAtt3D TBRIK where
instance ITObject TBRIK where
  draw = xform1 c_tbrik_draw
  findObject = xform1 c_tbrik_findobject
  getName = xform0 c_tbrik_getname
  isA = xform0 c_tbrik_isa
  isFolder = xform0 c_tbrik_isfolder
  isEqual = xform1 c_tbrik_isequal
  isSortable = xform0 c_tbrik_issortable
  paint = xform1 c_tbrik_paint
  printObj = xform1 c_tbrik_printobj
  recursiveRemove = xform1 c_tbrik_recursiveremove
  saveAs = xform2 c_tbrik_saveas
  useCurrentStyle = xform0 c_tbrik_usecurrentstyle
  write = xform3 c_tbrik_write
instance IDeletable TBRIK where
  delete = xform0 c_tbrik_delete

instance ITBRIK (Exist TBRIK) where

instance ITShape (Exist TBRIK) where

instance ITNamed (Exist TBRIK) where
  setName (ETBRIK x) = setName x
  setNameTitle (ETBRIK x) = setNameTitle x
  setTitle (ETBRIK x) = setTitle x
instance ITAttLine (Exist TBRIK) where
  getLineColor (ETBRIK x) = getLineColor x
  getLineStyle (ETBRIK x) = getLineStyle x
  getLineWidth (ETBRIK x) = getLineWidth x
  resetAttLine (ETBRIK x) = resetAttLine x
  setLineAttributes (ETBRIK x) = setLineAttributes x
  setLineColor (ETBRIK x) = setLineColor x
  setLineStyle (ETBRIK x) = setLineStyle x
  setLineWidth (ETBRIK x) = setLineWidth x
instance ITAttFill (Exist TBRIK) where
  setFillColor (ETBRIK x) = setFillColor x
  setFillStyle (ETBRIK x) = setFillStyle x
instance ITAtt3D (Exist TBRIK) where

instance ITObject (Exist TBRIK) where
  draw (ETBRIK x) = draw x
  findObject (ETBRIK x) = findObject x
  getName (ETBRIK x) = getName x
  isA (ETBRIK x) = isA x
  isFolder (ETBRIK x) = isFolder x
  isEqual (ETBRIK x) = isEqual x
  isSortable (ETBRIK x) = isSortable x
  paint (ETBRIK x) = paint x
  printObj (ETBRIK x) = printObj x
  recursiveRemove (ETBRIK x) = recursiveRemove x
  saveAs (ETBRIK x) = saveAs x
  useCurrentStyle (ETBRIK x) = useCurrentStyle x
  write (ETBRIK x) = write x
instance IDeletable (Exist TBRIK) where
  delete (ETBRIK x) = delete x


newTBRIK :: String -> String -> String -> Double -> Double -> Double -> IO TBRIK
newTBRIK = xform5 c_tbrik_newtbrik





instance FPtr (Exist TBRIK) where
  type Raw (Exist TBRIK) = RawTBRIK
  get_fptr (ETBRIK obj) = castForeignPtr (get_fptr obj)
  cast_fptr_to_obj fptr = ETBRIK (cast_fptr_to_obj (fptr :: ForeignPtr RawTBRIK) :: TBRIK)