-- GENERATED by C->Haskell Compiler, version 0.18.2 The shapeless maps, 31 Oct 2014 (Haskell)
-- Edit the ORIGNAL .chs file instead!


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

     -- * Dial functions
     --
     -- $Dialfunctions
    )
where



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

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

{-# LINE 27 "src/Graphics/UI/FLTK/LowLevel/Dial.chs" #-}

dialNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (String) -> IO ((Ptr ()))
dialNewWithLabel' 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 
  dialNewWithLabel''_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 28 "src/Graphics/UI/FLTK/LowLevel/Dial.chs" #-}

dialNew :: Rectangle -> Maybe String -> IO (Ref Dial)
dialNew rectangle l'=
    let (x_pos, y_pos, width, height) = fromRectangle rectangle
    in case l' of
        Nothing -> dialNew' x_pos y_pos width height >>=
                             toRef
        Just l -> dialNewWithLabel' x_pos y_pos width height l >>=
                               toRef

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

{-# LINE 38 "src/Graphics/UI/FLTK/LowLevel/Dial.chs" #-}

instance (impl ~ (IO ())) => Op (Destroy ()) Dial orig impl where
  runOp _ _ win = swapRef win $ \winPtr -> do
    dialDestroy' winPtr
    return nullPtr

setAngle1' :: (Ptr ()) -> (CShort) -> IO ()
setAngle1' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  setAngle1''_ a1' a2' >>
  return ()

{-# LINE 44 "src/Graphics/UI/FLTK/LowLevel/Dial.chs" #-}

instance (impl ~ ( Angle -> IO ())) => Op (SetAngle1 ()) Dial orig impl where
  runOp _ _ dial (Angle a) = withRef dial $ \dialPtr -> setAngle1' dialPtr a
setAngle2' :: (Ptr ()) -> (CShort) -> IO ()
setAngle2' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  setAngle2''_ a1' a2' >>
  return ()

{-# LINE 47 "src/Graphics/UI/FLTK/LowLevel/Dial.chs" #-}

instance (impl ~ ( Angle -> IO ())) => Op (SetAngle2 ()) Dial orig impl where
  runOp _ _ dial (Angle a) = withRef dial $ \dialPtr -> setAngle2' dialPtr a
angle1' :: (Ptr ()) -> IO ((CShort))
angle1' a1 =
  let {a1' = id a1} in 
  angle1''_ a1' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 50 "src/Graphics/UI/FLTK/LowLevel/Dial.chs" #-}

instance (impl ~ ( IO (Angle))) => Op (GetAngle1 ()) Dial orig impl where
  runOp _ _ dial = withRef dial $ \dialPtr -> angle1' dialPtr >>= return . Angle
angle2' :: (Ptr ()) -> IO ((CShort))
angle2' a1 =
  let {a1' = id a1} in 
  angle2''_ a1' >>= \res ->
  let {res' = id res} in
  return (res')

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

instance (impl ~ ( IO (Angle))) => Op (GetAngle2 ()) Dial orig impl where
  runOp _ _ dial = withRef dial $ \dialPtr -> angle2' dialPtr >>= return . Angle
dialHandle' :: (Ptr ()) -> (CInt) -> IO ((Int))
dialHandle' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  dialHandle''_ a1' a2' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

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

instance (impl ~ (Event -> IO Int)) => Op (Handle ()) Dial orig impl where
  runOp _ _ dial event = withRef dial (\p -> dialHandle' p (fromIntegral . fromEnum $ event))
instance (impl ~ ( Angle -> Angle -> IO ())) => Op (SetAngles ()) Dial orig impl where
  runOp _ _ dial a1' a2' = do
    setAngle1 dial a1'
    setAngle2 dial a2'

-- $Dialfunctions
--
-- @
-- destroy :: 'Ref' 'Dial' -> 'IO' ()
--
-- getAngle1 :: 'Ref' 'Dial' -> 'IO' 'Angle'
--
-- getAngle2 :: 'Ref' 'Dial' -> 'IO' 'Angle'
--
-- handle :: 'Ref' 'Dial' -> 'Event' -> 'IO' 'Int'
--
-- setAngle1 :: 'Ref' 'Dial' -> 'Angle' -> 'IO' ()
--
-- setAngle2 :: 'Ref' 'Dial' -> 'Angle' -> 'IO' ()
--
-- setAngles :: 'Ref' 'Dial' -> 'Angle' -> 'Angle' -> 'IO' ()
-- @

-- $hierarchy
-- @
-- "Graphics.UI.FLTK.LowLevel.Widget"
--  |
--  v
-- "Graphics.UI.FLTK.LowLevel.Valuator"
--  |
--  v
-- "Graphics.UI.FLTK.LowLevel.Dial"
-- @
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Dial_New"
  dialNew''_ :: (CInt -> (CInt -> (CInt -> (CInt -> (IO (Ptr ()))))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Dial_New_WithLabel"
  dialNewWithLabel''_ :: (CInt -> (CInt -> (CInt -> (CInt -> ((Ptr CChar) -> (IO (Ptr ())))))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Dial_Destroy"
  dialDestroy''_ :: ((Ptr ()) -> (IO ()))

foreign import ccall unsafe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Dial_set_angle1"
  setAngle1''_ :: ((Ptr ()) -> (CShort -> (IO ())))

foreign import ccall unsafe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Dial_set_angle2"
  setAngle2''_ :: ((Ptr ()) -> (CShort -> (IO ())))

foreign import ccall unsafe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Dial_angle1"
  angle1''_ :: ((Ptr ()) -> (IO CShort))

foreign import ccall unsafe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Dial_angle2"
  angle2''_ :: ((Ptr ()) -> (IO CShort))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Dial_handle"
  dialHandle''_ :: ((Ptr ()) -> (CInt -> (IO CInt)))