module Graphics.UI.FLTK.LowLevel.Spinner
(
spinnerNew,
SpinnerType(..)
)
where
import qualified Foreign.C.String as C2HSImp
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 SpinnerType = FloatSpinnerType
| IntSpinnerType
deriving (Show,Eq)
instance Enum SpinnerType where
succ FloatSpinnerType = IntSpinnerType
succ IntSpinnerType = error "SpinnerType.succ: IntSpinnerType has no successor"
pred IntSpinnerType = FloatSpinnerType
pred FloatSpinnerType = error "SpinnerType.pred: FloatSpinnerType 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 IntSpinnerType
fromEnum FloatSpinnerType = 1
fromEnum IntSpinnerType = 2
toEnum 1 = FloatSpinnerType
toEnum 2 = IntSpinnerType
toEnum unmatched = error ("SpinnerType.toEnum: Cannot match " ++ show unmatched)
spinnerNew' :: (Int) -> (Int) -> (Int) -> (Int) -> IO ((Ptr ()))
spinnerNew' a1 a2 a3 a4 =
let {a1' = fromIntegral a1} in
let {a2' = fromIntegral a2} in
let {a3' = fromIntegral a3} in
let {a4' = fromIntegral a4} in
spinnerNew''_ a1' a2' a3' a4' >>= \res ->
let {res' = id res} in
return (res')
spinnerNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (String) -> IO ((Ptr ()))
spinnerNewWithLabel' 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
spinnerNewWithLabel''_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = id res} in
return (res')
spinnerNew :: Rectangle -> Maybe String -> IO (Ref Spinner)
spinnerNew rectangle l'=
let (x_pos, y_pos, width, height) = fromRectangle rectangle
in case l' of
Nothing -> spinnerNew' x_pos y_pos width height >>=
toRef
Just l -> spinnerNewWithLabel' x_pos y_pos width height l >>=
toRef
spinnerHandle' :: (Ptr ()) -> (CInt) -> IO ((Int))
spinnerHandle' a1 a2 =
let {a1' = id a1} in
let {a2' = id a2} in
spinnerHandle''_ a1' a2' >>= \res ->
let {res' = fromIntegral res} in
return (res')
instance (impl ~ (Event -> IO Int)) => Op (Handle ()) Spinner orig impl where
runOp _ _ spinner event = withRef spinner (\p -> spinnerHandle' p (fromIntegral . fromEnum $ event))
setTextfont' :: (Ptr ()) -> (Font) -> IO ()
setTextfont' a1 a2 =
let {a1' = id a1} in
let {a2' = cFromFont a2} in
setTextfont''_ a1' a2' >>
return ()
instance (impl ~ (Font -> IO ())) => Op (SetTextfont ()) Spinner orig impl where
runOp _ _ spinner text = withRef spinner $ \spinnerPtr -> setTextfont' spinnerPtr text
textfont' :: (Ptr ()) -> IO ((Font))
textfont' a1 =
let {a1' = id a1} in
textfont''_ a1' >>= \res ->
let {res' = cToFont res} in
return (res')
instance (impl ~ ( IO (Font))) => Op (GetTextfont ()) Spinner orig impl where
runOp _ _ spinner = withRef spinner $ \spinnerPtr -> textfont' spinnerPtr
setTextsize' :: (Ptr ()) -> (CInt) -> IO ()
setTextsize' a1 a2 =
let {a1' = id a1} in
let {a2' = id a2} in
setTextsize''_ a1' a2' >>
return ()
instance (impl ~ (FontSize -> IO ())) => Op (SetTextsize ()) Spinner orig impl where
runOp _ _ spinner (FontSize text) = withRef spinner $ \spinnerPtr -> setTextsize' spinnerPtr text
textsize' :: (Ptr ()) -> IO ((CInt))
textsize' a1 =
let {a1' = id a1} in
textsize''_ a1' >>= \res ->
let {res' = id res} in
return (res')
instance (impl ~ ( IO (FontSize))) => Op (GetTextsize ()) Spinner orig impl where
runOp _ _ spinner = withRef spinner $ \spinnerPtr -> textsize' spinnerPtr >>= return . FontSize
setTextcolor' :: (Ptr ()) -> (Color) -> IO ()
setTextcolor' a1 a2 =
let {a1' = id a1} in
let {a2' = cFromColor a2} in
setTextcolor''_ a1' a2' >>
return ()
instance (impl ~ (Color -> IO ())) => Op (SetTextcolor ()) Spinner orig impl where
runOp _ _ spinner text = withRef spinner $ \spinnerPtr -> setTextcolor' spinnerPtr text
textcolor' :: (Ptr ()) -> IO ((Color))
textcolor' a1 =
let {a1' = id a1} in
textcolor''_ a1' >>= \res ->
let {res' = cToColor res} in
return (res')
instance (impl ~ ( IO (Color))) => Op (GetTextcolor ()) Spinner orig impl where
runOp _ _ spinner = withRef spinner $ \spinnerPtr -> textcolor' spinnerPtr
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')
instance (impl ~ (SpinnerType -> IO ())) => Op (SetType ()) Spinner 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')
instance (impl ~ IO (SpinnerType)) => Op (GetType_ ()) Spinner orig impl where
runOp _ _ widget = withRef widget $ \widgetPtr -> type' widgetPtr >>= return . toEnum . fromInteger . toInteger
set_format' :: (Ptr ()) -> (String) -> IO ((()))
set_format' a1 a2 =
let {a1' = id a1} in
C2HSImp.withCString a2 $ \a2' ->
set_format''_ a1' a2' >>= \res ->
let {res' = supressWarningAboutRes res} in
return (res')
instance (impl ~ (String -> IO ())) => Op (SetFormat ()) Spinner orig impl where
runOp _ _ spinner f = withRef spinner $ \spinnerPtr -> set_format' spinnerPtr f
format' :: (Ptr ()) -> IO ((String))
format' a1 =
let {a1' = id a1} in
format''_ a1' >>= \res ->
let {res' = unsafeFromCString res} in
return (res')
instance (impl ~ ( IO (Maybe String))) => Op (GetFormat ()) Spinner orig impl where
runOp _ _ spinner = withRef spinner $ \spinnerPtr -> format' spinnerPtr >>= \s ->
if (null s) then return Nothing else return (Just s)
value' :: (Ptr ()) -> IO ((Double))
value' a1 =
let {a1' = id a1} in
value''_ a1' >>= \res ->
let {res' = realToFrac res} in
return (res')
instance (impl ~ ( IO (Double))) => Op (GetValue ()) Spinner orig impl where
runOp _ _ spinner = withRef spinner $ \spinnerPtr -> value' spinnerPtr
setValue' :: (Ptr ()) -> (Double) -> IO ((()))
setValue' a1 a2 =
let {a1' = id a1} in
let {a2' = realToFrac a2} in
setValue''_ a1' a2' >>= \res ->
let {res' = supressWarningAboutRes res} in
return (res')
instance (impl ~ (Double -> IO ())) => Op (SetValue ()) Spinner orig impl where
runOp _ _ spinner v = withRef spinner $ \spinnerPtr -> setValue' spinnerPtr v
setStep' :: (Ptr ()) -> (Double) -> IO ((()))
setStep' a1 a2 =
let {a1' = id a1} in
let {a2' = realToFrac a2} in
setStep''_ a1' a2' >>= \res ->
let {res' = supressWarningAboutRes res} in
return (res')
instance (impl ~ (Double -> IO ())) => Op (SetStep ()) Spinner orig impl where
runOp _ _ spinner r = withRef spinner $ \spinnerPtr -> setStep' spinnerPtr r
step' :: (Ptr ()) -> IO ((Double))
step' a1 =
let {a1' = id a1} in
step''_ a1' >>= \res ->
let {res' = realToFrac res} in
return (res')
instance (impl ~ ( IO (Double))) => Op (GetStep ()) Spinner orig impl where
runOp _ _ spinner = withRef spinner $ \spinnerPtr -> step' spinnerPtr
maximum' :: (Ptr ()) -> IO ((Double))
maximum' a1 =
let {a1' = id a1} in
maximum''_ a1' >>= \res ->
let {res' = realToFrac res} in
return (res')
instance (impl ~ ( IO (Double))) => Op (GetMaximum ()) Spinner orig impl where
runOp _ _ valuator = withRef valuator $ \valuatorPtr -> maximum' valuatorPtr
setMaximum' :: (Ptr ()) -> (Double) -> IO ((()))
setMaximum' a1 a2 =
let {a1' = id a1} in
let {a2' = realToFrac a2} in
setMaximum''_ a1' a2' >>= \res ->
let {res' = supressWarningAboutRes res} in
return (res')
instance (impl ~ (Double -> IO ())) => Op (SetMaximum ()) Spinner orig impl where
runOp _ _ valuator a = withRef valuator $ \valuatorPtr -> setMaximum' valuatorPtr a
minimum' :: (Ptr ()) -> IO ((Double))
minimum' a1 =
let {a1' = id a1} in
minimum''_ a1' >>= \res ->
let {res' = realToFrac res} in
return (res')
instance (impl ~ ( IO (Double))) => Op (GetMinimum ()) Spinner orig impl where
runOp _ _ valuator = withRef valuator $ \valuatorPtr -> minimum' valuatorPtr
setMinimum' :: (Ptr ()) -> (Double) -> IO ((()))
setMinimum' a1 a2 =
let {a1' = id a1} in
let {a2' = realToFrac a2} in
setMinimum''_ a1' a2' >>= \res ->
let {res' = supressWarningAboutRes res} in
return (res')
instance (impl ~ (Double -> IO ())) => Op (SetMinimum ()) Spinner orig impl where
runOp _ _ valuator a = withRef valuator $ \valuatorPtr -> setMinimum' valuatorPtr a
range' :: (Ptr ()) -> (Double) -> (Double) -> IO ((()))
range' a1 a2 a3 =
let {a1' = id a1} in
let {a2' = realToFrac a2} in
let {a3' = realToFrac a3} in
range''_ a1' a2' a3' >>= \res ->
let {res' = supressWarningAboutRes res} in
return (res')
instance (impl ~ (Double -> Double -> IO ())) => Op (Range ()) Spinner orig impl where
runOp _ _ valuator a b = withRef valuator $ \valuatorPtr -> range' valuatorPtr a b
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_New"
spinnerNew''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO (C2HSImp.Ptr ()))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_New_WithLabel"
spinnerNewWithLabel''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO (C2HSImp.Ptr ())))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_handle"
spinnerHandle''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_set_textfont"
setTextfont''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_textfont"
textfont''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_set_textsize"
setTextsize''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_textsize"
textsize''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_set_textcolor"
setTextcolor''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CUInt -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_textcolor"
textcolor''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CUInt))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_set_type"
setType''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CUChar -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_type"
type''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CUChar))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_set_format"
set_format''_ :: ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_format"
format''_ :: ((C2HSImp.Ptr ()) -> (IO (C2HSImp.Ptr C2HSImp.CChar)))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_value"
value''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CDouble))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_set_value"
setValue''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CDouble -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_set_step"
setStep''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CDouble -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_step"
step''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CDouble))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_maximum"
maximum''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CDouble))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_set_maximum"
setMaximum''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CDouble -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_minimum"
minimum''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CDouble))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_set_minimum"
setMinimum''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CDouble -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Spinner.chs.h Fl_Spinner_range"
range''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (IO ()))))