{-# 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
(
dialNew,
DialType(..)
)
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
data DialType = NormalDialType
| LineDialType
| FillDialType
deriving (Show,Eq)
instance Enum DialType where
succ NormalDialType = LineDialType
succ LineDialType = FillDialType
succ FillDialType = error "DialType.succ: FillDialType has no successor"
pred LineDialType = NormalDialType
pred FillDialType = LineDialType
pred NormalDialType = error "DialType.pred: NormalDialType has no predecessor"
enumFromTo from to = go from
where
end = fromEnum to
go v = case compare (fromEnum v) end of
LT -> v : go (succ v)
EQ -> [v]
GT -> []
enumFrom from = enumFromTo from FillDialType
fromEnum NormalDialType = 0
fromEnum LineDialType = 1
fromEnum FillDialType = 2
toEnum 0 = NormalDialType
toEnum 1 = LineDialType
toEnum 2 = FillDialType
toEnum unmatched = error ("DialType.toEnum: Cannot match " ++ show unmatched)
{-# LINE 35 "src/Graphics/UI/FLTK/LowLevel/Dial.chs" #-}
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 36 "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 37 "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 47 "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 53 "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 56 "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 59 "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 62 "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 65 "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'
setType' :: (Ptr ()) -> (Word8) -> IO ((()))
setType' a1 a2 =
let {a1' = id a1} in
let {a2' = fromIntegral a2} in
setType''_ a1' a2' >>= \res ->
let {res' = supressWarningAboutRes res} in
return (res')
{-# LINE 72 "src/Graphics/UI/FLTK/LowLevel/Dial.chs" #-}
instance (impl ~ (DialType -> IO ())) => Op (SetType ()) Dial orig impl where
runOp _ _ widget t = withRef widget $ \widgetPtr -> setType' widgetPtr (fromInteger $ toInteger $ fromEnum t)
type' :: (Ptr ()) -> IO ((Word8))
type' a1 =
let {a1' = id a1} in
type''_ a1' >>= \res ->
let {res' = fromIntegral res} in
return (res')
{-# LINE 75 "src/Graphics/UI/FLTK/LowLevel/Dial.chs" #-}
instance (impl ~ IO (DialType)) => Op (GetType_ ()) Dial orig impl where
runOp _ _ widget = withRef widget $ \widgetPtr -> type' widgetPtr >>= return . toEnum . fromInteger . toInteger
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Dial_New"
dialNew''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO (C2HSImp.Ptr ()))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Dial_New_WithLabel"
dialNewWithLabel''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO (C2HSImp.Ptr ())))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Dial_Destroy"
dialDestroy''_ :: ((C2HSImp.Ptr ()) -> (IO ()))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Dial_set_angle1"
setAngle1''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CShort -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Dial_set_angle2"
setAngle2''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CShort -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Dial_angle1"
angle1''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CShort))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Dial_angle2"
angle2''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CShort))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Dial_handle"
dialHandle''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Widget_set_type"
setType''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CUChar -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Dial.chs.h Fl_Widget_type"
type''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CUChar))