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

module HROOT.Class.TBox.Implementation where


import HROOT.TypeCast

import HROOT.Class.TBox.RawType
import HROOT.Class.TBox.FFI
import HROOT.Class.TBox.Interface
import HROOT.Class.TBox.Cast
import HROOT.Class.TClass.RawType
import HROOT.Class.TClass.Cast
import HROOT.Class.TClass.Interface
import HROOT.Class.TObject.RawType
import HROOT.Class.TObject.Cast
import HROOT.Class.TObject.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.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 ITBox TBox where
instance ITObject TBox where
  draw = xform1 c_tbox_draw
  findObject = xform1 c_tbox_findobject
  getName = xform0 c_tbox_getname
  isA = xform0 c_tbox_isa
  isFolder = xform0 c_tbox_isfolder
  isEqual = xform1 c_tbox_isequal
  isSortable = xform0 c_tbox_issortable
  paint = xform1 c_tbox_paint
  printObj = xform1 c_tbox_printobj
  recursiveRemove = xform1 c_tbox_recursiveremove
  saveAs = xform2 c_tbox_saveas
  useCurrentStyle = xform0 c_tbox_usecurrentstyle
  write = xform3 c_tbox_write
instance ITAttLine TBox where
  getLineColor = xform0 c_tbox_getlinecolor
  getLineStyle = xform0 c_tbox_getlinestyle
  getLineWidth = xform0 c_tbox_getlinewidth
  resetAttLine = xform1 c_tbox_resetattline
  setLineAttributes = xform0 c_tbox_setlineattributes
  setLineColor = xform1 c_tbox_setlinecolor
  setLineStyle = xform1 c_tbox_setlinestyle
  setLineWidth = xform1 c_tbox_setlinewidth
instance ITAttFill TBox where
  setFillColor = xform1 c_tbox_setfillcolor
  setFillStyle = xform1 c_tbox_setfillstyle
instance IDeletable TBox where
  delete = xform0 c_tbox_delete

instance ITBox (Exist TBox) where

instance ITObject (Exist TBox) where
  draw (ETBox x) = draw x
  findObject (ETBox x) = findObject x
  getName (ETBox x) = getName x
  isA (ETBox x) = isA x
  isFolder (ETBox x) = isFolder x
  isEqual (ETBox x) = isEqual x
  isSortable (ETBox x) = isSortable x
  paint (ETBox x) = paint x
  printObj (ETBox x) = printObj x
  recursiveRemove (ETBox x) = recursiveRemove x
  saveAs (ETBox x) = saveAs x
  useCurrentStyle (ETBox x) = useCurrentStyle x
  write (ETBox x) = write x
instance ITAttLine (Exist TBox) where
  getLineColor (ETBox x) = getLineColor x
  getLineStyle (ETBox x) = getLineStyle x
  getLineWidth (ETBox x) = getLineWidth x
  resetAttLine (ETBox x) = resetAttLine x
  setLineAttributes (ETBox x) = setLineAttributes x
  setLineColor (ETBox x) = setLineColor x
  setLineStyle (ETBox x) = setLineStyle x
  setLineWidth (ETBox x) = setLineWidth x
instance ITAttFill (Exist TBox) where
  setFillColor (ETBox x) = setFillColor x
  setFillStyle (ETBox x) = setFillStyle x
instance IDeletable (Exist TBox) where
  delete (ETBox x) = delete x


newTBox :: Double -> Double -> Double -> Double -> IO TBox
newTBox = xform3 c_tbox_newtbox





instance FPtr (Exist TBox) where
  type Raw (Exist TBox) = RawTBox
  get_fptr (ETBox obj) = castForeignPtr (get_fptr obj)
  cast_fptr_to_obj fptr = ETBox (cast_fptr_to_obj (fptr :: ForeignPtr RawTBox) :: TBox)