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

module HROOT.Class.TAttText.Implementation where


import HROOT.TypeCast

import HROOT.Class.TAttText.RawType
import HROOT.Class.TAttText.FFI
import HROOT.Class.TAttText.Interface
import HROOT.Class.TAttText.Cast

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 ITAttText TAttText where
  getTextAlign = xform0 c_tatttext_gettextalign
  getTextAngle = xform0 c_tatttext_gettextangle
  getTextColor = xform0 c_tatttext_gettextcolor
  getTextFont = xform0 c_tatttext_gettextfont
  getTextSize = xform0 c_tatttext_gettextsize
  resetAttText = xform1 c_tatttext_resetatttext
  setTextAttributes = xform0 c_tatttext_settextattributes
  setTextAlign = xform1 c_tatttext_settextalign
  setTextAngle = xform1 c_tatttext_settextangle
  setTextColor = xform1 c_tatttext_settextcolor
  setTextFont = xform1 c_tatttext_settextfont
  setTextSize = xform1 c_tatttext_settextsize
  setTextSizePixels = xform1 c_tatttext_settextsizepixels
instance IDeletable TAttText where
  delete = xform0 c_tatttext_delete

instance ITAttText (Exist TAttText) where
  getTextAlign (ETAttText x) = getTextAlign x
  getTextAngle (ETAttText x) = getTextAngle x
  getTextColor (ETAttText x) = getTextColor x
  getTextFont (ETAttText x) = getTextFont x
  getTextSize (ETAttText x) = getTextSize x
  resetAttText (ETAttText x) = resetAttText x
  setTextAttributes (ETAttText x) = setTextAttributes x
  setTextAlign (ETAttText x) = setTextAlign x
  setTextAngle (ETAttText x) = setTextAngle x
  setTextColor (ETAttText x) = setTextColor x
  setTextFont (ETAttText x) = setTextFont x
  setTextSize (ETAttText x) = setTextSize x
  setTextSizePixels (ETAttText x) = setTextSizePixels x
instance IDeletable (Exist TAttText) where
  delete (ETAttText x) = delete x


newTAttText :: Int -> Double -> Int -> Int -> Double -> IO TAttText
newTAttText = xform4 c_tatttext_newtatttext



instance FPtr (Exist TAttText) where
  type Raw (Exist TAttText) = RawTAttText
  get_fptr (ETAttText obj) = castForeignPtr (get_fptr obj)
  cast_fptr_to_obj fptr = ETAttText (cast_fptr_to_obj (fptr :: ForeignPtr RawTAttText) :: TAttText)