-- GENERATED by C->Haskell Compiler, version 0.27.1 Eternal Sunshine, 29 November 2015 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "src/Graphics/UI/FLTK/LowLevel/Timer.chs" #-}
{-# LANGUAGE CPP, ExistentialQuantification, TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses, FlexibleContexts, ScopedTypeVariables #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Graphics.UI.FLTK.LowLevel.Timer
    (
     -- * Constructor
     timerNew,
     -- * Hierarchy
     --
     -- $hierarchy

     valueTimerNew,
     hiddenTimerNew
     -- * Functions
     --
     -- $functions
    )
where
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.Ptr as C2HSImp





import C2HS hiding (cFromEnum, cFromBool, cToBool,cToEnum)
import Foreign.C.Types
import Graphics.UI.FLTK.LowLevel.Fl_Enumerations
import Graphics.UI.FLTK.LowLevel.Fl_Types
import Graphics.UI.FLTK.LowLevel.Utils
import Graphics.UI.FLTK.LowLevel.Hierarchy
import Graphics.UI.FLTK.LowLevel.Dispatch

timerNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (String) -> IO ((Ptr ()))
timerNewWithLabel' a1 a2 a3 a4 a5 =
  let {a1' = fromIntegral a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = fromIntegral a4} in 
  let {a5' = unsafeToCString a5} in 
  timerNewWithLabel''_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 29 "src/Graphics/UI/FLTK/LowLevel/Timer.chs" #-}

timerNew :: Rectangle -> String -> IO (Ref Timer)
timerNew rectangle l'=
    let (x_pos, y_pos, width, height) = fromRectangle rectangle
    in timerNewWithLabel' x_pos y_pos width height l' >>= toRef
valueTimerNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (String) -> IO ((Ptr ()))
valueTimerNewWithLabel' a1 a2 a3 a4 a5 =
  let {a1' = fromIntegral a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = fromIntegral a4} in 
  let {a5' = unsafeToCString a5} in 
  valueTimerNewWithLabel''_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 34 "src/Graphics/UI/FLTK/LowLevel/Timer.chs" #-}

valueTimerNew :: Rectangle -> String -> IO (Ref ValueTimer)
valueTimerNew rectangle l'=
    let (x_pos, y_pos, width, height) = fromRectangle rectangle
    in
    valueTimerNewWithLabel' x_pos y_pos width height l' >>= toRef

hiddenTimerNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (String) -> IO ((Ptr ()))
hiddenTimerNewWithLabel' a1 a2 a3 a4 a5 =
  let {a1' = fromIntegral a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = fromIntegral a4} in 
  let {a5' = unsafeToCString a5} in 
  hiddenTimerNewWithLabel''_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 41 "src/Graphics/UI/FLTK/LowLevel/Timer.chs" #-}

hiddenTimerNew :: Rectangle -> String -> IO (Ref HiddenTimer)
hiddenTimerNew rectangle l'=
    let (x_pos, y_pos, width, height) = fromRectangle rectangle
    in
    hiddenTimerNewWithLabel' x_pos y_pos width height l' >>= toRef

timerDestroy' :: (Ptr ()) -> IO ((()))
timerDestroy' a1 =
  let {a1' = id a1} in 
  timerDestroy''_ a1' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')

{-# LINE 48 "src/Graphics/UI/FLTK/LowLevel/Timer.chs" #-}

instance (impl ~ (IO ())) => Op (Destroy ()) Timer orig impl where
  runOp _ _ win = swapRef win $ \winPtr -> do
                                        timerDestroy' winPtr
                                        return nullPtr
timerHandle' :: (Ptr ()) -> (CInt) -> IO ((Int))
timerHandle' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  timerHandle''_ a1' a2' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 53 "src/Graphics/UI/FLTK/LowLevel/Timer.chs" #-}

instance (impl ~ (Event -> IO Int)) => Op (Handle ()) Timer orig impl where
  runOp _ _ timer event = withRef timer (\p -> timerHandle' p (fromIntegral . fromEnum $ event))
direction' :: (Ptr ()) -> IO ((CChar))
direction' a1 =
  let {a1' = id a1} in 
  direction''_ a1' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 56 "src/Graphics/UI/FLTK/LowLevel/Timer.chs" #-}

instance (impl ~ ( IO (CountDirection))) => Op (GetDirection ()) Timer orig impl where
  runOp _ _ adjuster = withRef adjuster $ \adjusterPtr -> direction' adjusterPtr >>= return . ccharToCountDirection
setDirection' :: (Ptr ()) -> (CChar) -> IO ()
setDirection' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  setDirection''_ a1' a2' >>
  return ()

{-# LINE 59 "src/Graphics/UI/FLTK/LowLevel/Timer.chs" #-}

instance (impl ~ (CountDirection ->  IO ())) => Op (SetDirection ()) Timer orig impl where
  runOp _ _ adjuster d = withRef adjuster $ \adjusterPtr -> setDirection' adjusterPtr (countDirectionToCChar d)
value' :: (Ptr ()) -> IO ((Double))
value' a1 =
  let {a1' = id a1} in 
  value''_ a1' >>= \res ->
  let {res' = realToFrac res} in
  return (res')

{-# LINE 62 "src/Graphics/UI/FLTK/LowLevel/Timer.chs" #-}

instance (impl ~ ( IO (Double))) => Op (GetValue ()) Timer orig impl where
  runOp _ _ adjuster = withRef adjuster $ \adjusterPtr -> value' adjusterPtr
setValue' :: (Ptr ()) -> (Double) -> IO ()
setValue' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = realToFrac a2} in 
  setValue''_ a1' a2' >>
  return ()

{-# LINE 65 "src/Graphics/UI/FLTK/LowLevel/Timer.chs" #-}

instance (impl ~ (Double ->  IO ())) => Op (SetValue ()) Timer orig impl where
  runOp _ _ adjuster value = withRef adjuster $ \adjusterPtr -> setValue' adjusterPtr value
suspended' :: (Ptr ()) -> IO ((Bool))
suspended' a1 =
  let {a1' = id a1} in 
  suspended''_ a1' >>= \res ->
  let {res' = cToBool res} in
  return (res')

{-# LINE 68 "src/Graphics/UI/FLTK/LowLevel/Timer.chs" #-}

instance (impl ~ ( IO (Bool))) => Op (GetSuspended ()) Timer orig impl where
  runOp _ _ adjuster = withRef adjuster $ \adjusterPtr -> suspended' adjusterPtr
setSuspended' :: (Ptr ()) -> (Bool) -> IO ()
setSuspended' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = cFromBool a2} in 
  setSuspended''_ a1' a2' >>
  return ()

{-# LINE 71 "src/Graphics/UI/FLTK/LowLevel/Timer.chs" #-}

instance (impl ~ (Bool ->  IO ())) => Op (SetSuspended ()) Timer orig impl where
  runOp _ _ adjuster s = withRef adjuster $ \adjusterPtr -> setSuspended' adjusterPtr s

-- $functions
-- @
--
-- destroy :: 'Ref' 'Timer' -> 'IO' ()
--
-- getDirection :: 'Ref' 'Timer' -> 'IO' 'CountDirection'
--
-- getSuspended :: 'Ref' 'Timer' -> 'IO' 'Bool'
--
-- getValue :: 'Ref' 'Timer' -> 'IO' 'Double'
--
-- handle :: 'Ref' 'Timer' -> 'Event' -> 'IO' 'Int'
--
-- setDirection :: 'Ref' 'Timer' -> 'CountDirection' -> 'IO' ()
--
-- setSuspended :: 'Ref' 'Timer' -> 'Bool' -> 'IO' ()
--
-- setValue :: 'Ref' 'Timer' -> 'Double' -> 'IO' ()
-- @

-- $hierarchy
-- @
-- "Graphics.UI.FLTK.LowLevel.Widget"
--  |
--  v
-- "Graphics.UI.FLTK.LowLevel.Timer"
-- @
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Timer.chs.h Fl_Timer_New"
  timerNewWithLabel''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO (C2HSImp.Ptr ())))))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Timer.chs.h Fl_Value_Timer_New"
  valueTimerNewWithLabel''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO (C2HSImp.Ptr ())))))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Timer.chs.h Fl_Hidden_Timer_New"
  hiddenTimerNewWithLabel''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO (C2HSImp.Ptr ())))))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Timer.chs.h Fl_Timer_Destroy"
  timerDestroy''_ :: ((C2HSImp.Ptr ()) -> (IO ()))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Timer.chs.h Fl_Timer_handle"
  timerHandle''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Timer.chs.h Fl_Timer_direction"
  direction''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CChar))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Timer.chs.h Fl_Timer_set_direction"
  setDirection''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CChar -> (IO ())))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Timer.chs.h Fl_Timer_value"
  value''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CDouble))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Timer.chs.h Fl_Timer_set_value"
  setValue''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CDouble -> (IO ())))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Timer.chs.h Fl_Timer_suspended"
  suspended''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CChar))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Timer.chs.h Fl_Timer_set_suspended"
  setSuspended''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CChar -> (IO ())))