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

module HROOT.Class.TAxis.Implementation where


import HROOT.TypeCast

import HROOT.Class.TAxis.RawType
import HROOT.Class.TAxis.FFI
import HROOT.Class.TAxis.Interface
import HROOT.Class.TAxis.Cast
import HROOT.Class.TClass.RawType
import HROOT.Class.TClass.Cast
import HROOT.Class.TClass.Interface
import HROOT.Class.TNamed.RawType
import HROOT.Class.TNamed.Cast
import HROOT.Class.TNamed.Interface
import HROOT.Class.TAttAxis.RawType
import HROOT.Class.TAttAxis.Cast
import HROOT.Class.TAttAxis.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 ITAxis TAxis where
  findBinTAxis = xform1 c_taxis_findbintaxis
  findFixBinTAxis = xform1 c_taxis_findfixbintaxis
  getBinCenterTAxis = xform1 c_taxis_getbincentertaxis
  getBinCenterLog = xform1 c_taxis_getbincenterlog
  getBinUpEdge = xform1 c_taxis_getbinupedge
  setTimeDisplay = xform1 c_taxis_settimedisplay
  setTimeFormat = xform1 c_taxis_settimeformat
  setTimeOffset = xform2 c_taxis_settimeoffset
instance ITNamed TAxis where
  setName = xform1 c_taxis_setname
  setNameTitle = xform2 c_taxis_setnametitle
  setTitle = xform1 c_taxis_settitle
instance ITAttAxis TAxis where
  getNdivisions = xform0 c_taxis_getndivisions
  getAxisColor = xform0 c_taxis_getaxiscolor
  getLabelColor = xform0 c_taxis_getlabelcolor
  getLabelFont = xform0 c_taxis_getlabelfont
  getLabelOffset = xform0 c_taxis_getlabeloffset
  getLabelSize = xform0 c_taxis_getlabelsize
  getTitleOffset = xform0 c_taxis_gettitleoffset
  getTitleSize = xform0 c_taxis_gettitlesize
  getTickLength = xform0 c_taxis_getticklength
  getTitleFont = xform0 c_taxis_gettitlefont
  setNdivisions = xform2 c_taxis_setndivisions
  setAxisColor = xform1 c_taxis_setaxiscolor
  setLabelColor = xform1 c_taxis_setlabelcolor
  setLabelFont = xform1 c_taxis_setlabelfont
  setLabelOffset = xform1 c_taxis_setlabeloffset
  setLabelSize = xform1 c_taxis_setlabelsize
  setTickLength = xform1 c_taxis_setticklength
  setTitleOffset = xform1 c_taxis_settitleoffset
  setTitleSize = xform1 c_taxis_settitlesize
  setTitleColor = xform1 c_taxis_settitlecolor
  setTitleFont = xform1 c_taxis_settitlefont
instance ITObject TAxis where
  draw = xform1 c_taxis_draw
  findObject = xform1 c_taxis_findobject
  getName = xform0 c_taxis_getname
  isA = xform0 c_taxis_isa
  isFolder = xform0 c_taxis_isfolder
  isEqual = xform1 c_taxis_isequal
  isSortable = xform0 c_taxis_issortable
  paint = xform1 c_taxis_paint
  printObj = xform1 c_taxis_printobj
  recursiveRemove = xform1 c_taxis_recursiveremove
  saveAs = xform2 c_taxis_saveas
  useCurrentStyle = xform0 c_taxis_usecurrentstyle
  write = xform3 c_taxis_write
instance IDeletable TAxis where
  delete = xform0 c_taxis_delete

instance ITAxis (Exist TAxis) where
  findBinTAxis (ETAxis x) = findBinTAxis x
  findFixBinTAxis (ETAxis x) = findFixBinTAxis x
  getBinCenterTAxis (ETAxis x) = getBinCenterTAxis x
  getBinCenterLog (ETAxis x) = getBinCenterLog x
  getBinUpEdge (ETAxis x) = getBinUpEdge x
  setTimeDisplay (ETAxis x) = setTimeDisplay x
  setTimeFormat (ETAxis x) = setTimeFormat x
  setTimeOffset (ETAxis x) = setTimeOffset x
instance ITNamed (Exist TAxis) where
  setName (ETAxis x) = setName x
  setNameTitle (ETAxis x) = setNameTitle x
  setTitle (ETAxis x) = setTitle x
instance ITAttAxis (Exist TAxis) where
  getNdivisions (ETAxis x) = getNdivisions x
  getAxisColor (ETAxis x) = getAxisColor x
  getLabelColor (ETAxis x) = getLabelColor x
  getLabelFont (ETAxis x) = getLabelFont x
  getLabelOffset (ETAxis x) = getLabelOffset x
  getLabelSize (ETAxis x) = getLabelSize x
  getTitleOffset (ETAxis x) = getTitleOffset x
  getTitleSize (ETAxis x) = getTitleSize x
  getTickLength (ETAxis x) = getTickLength x
  getTitleFont (ETAxis x) = getTitleFont x
  setNdivisions (ETAxis x) = setNdivisions x
  setAxisColor (ETAxis x) = setAxisColor x
  setLabelColor (ETAxis x) = setLabelColor x
  setLabelFont (ETAxis x) = setLabelFont x
  setLabelOffset (ETAxis x) = setLabelOffset x
  setLabelSize (ETAxis x) = setLabelSize x
  setTickLength (ETAxis x) = setTickLength x
  setTitleOffset (ETAxis x) = setTitleOffset x
  setTitleSize (ETAxis x) = setTitleSize x
  setTitleColor (ETAxis x) = setTitleColor x
  setTitleFont (ETAxis x) = setTitleFont x
instance ITObject (Exist TAxis) where
  draw (ETAxis x) = draw x
  findObject (ETAxis x) = findObject x
  getName (ETAxis x) = getName x
  isA (ETAxis x) = isA x
  isFolder (ETAxis x) = isFolder x
  isEqual (ETAxis x) = isEqual x
  isSortable (ETAxis x) = isSortable x
  paint (ETAxis x) = paint x
  printObj (ETAxis x) = printObj x
  recursiveRemove (ETAxis x) = recursiveRemove x
  saveAs (ETAxis x) = saveAs x
  useCurrentStyle (ETAxis x) = useCurrentStyle x
  write (ETAxis x) = write x
instance IDeletable (Exist TAxis) where
  delete (ETAxis x) = delete x


newTAxis :: Int -> Double -> Double -> IO TAxis
newTAxis = xform2 c_taxis_newtaxis

tAxisGetCenterLabels :: TAxis -> IO Int
tAxisGetCenterLabels = xform0 c_taxis_taxisgetcenterlabels

tAxisGetCenterTitle :: TAxis -> IO Int
tAxisGetCenterTitle = xform0 c_taxis_taxisgetcentertitle

instance FPtr (Exist TAxis) where
  type Raw (Exist TAxis) = RawTAxis
  get_fptr (ETAxis obj) = castForeignPtr (get_fptr obj)
  cast_fptr_to_obj fptr = ETAxis (cast_fptr_to_obj (fptr :: ForeignPtr RawTAxis) :: TAxis)