{-# LINE 1 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
{-# LANGUAGE CPP, TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses, FlexibleContexts #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Graphics.UI.FLTK.LowLevel.Clock
(
ClockType(..),
clockNew,
clockNewWithType,
Hour(..),
Minute(..),
Second(..),
ClockByTime (..),
ClockSinceEpoch(..),
ClockSetTimeType(..)
)
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
import qualified Data.Text as T
import Data.Char
data ClockType = SquareClock
| AnalogClock
| DigitalClock
| RoundClock
deriving (Show)
instance Enum ClockType where
succ SquareClock = RoundClock
succ AnalogClock = RoundClock
succ DigitalClock = RoundClock
succ RoundClock = error "ClockType.succ: RoundClock has no successor"
pred RoundClock = SquareClock
pred SquareClock = error "ClockType.pred: SquareClock has no predecessor"
pred AnalogClock = error "ClockType.pred: AnalogClock has no predecessor"
pred DigitalClock = error "ClockType.pred: DigitalClock 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 RoundClock
fromEnum SquareClock = 0
fromEnum AnalogClock = 0
fromEnum DigitalClock = 0
fromEnum RoundClock = 1
toEnum 0 = SquareClock
toEnum 1 = RoundClock
toEnum unmatched = error ("ClockType.toEnum: Cannot match " ++ show unmatched)
{-# LINE 42 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
newtype Hour = Hour Int
newtype Minute = Minute Int
newtype Second = Second Int
data ClockByTime = ClockByTime Hour Minute Second
data ClockSinceEpoch = ClockSinceEpoch Second
data ClockSetTimeType = ClockSetByTime ClockByTime | ClockSetSinceEpoch ClockSinceEpoch
clockNew' :: (Int) -> (Int) -> (Int) -> (Int) -> IO ((Ptr ()))
clockNew' a1 a2 a3 a4 =
let {a1' = fromIntegral a1} in
let {a2' = fromIntegral a2} in
let {a3' = fromIntegral a3} in
let {a4' = fromIntegral a4} in
clockNew''_ a1' a2' a3' a4' >>= \res ->
let {res' = id res} in
return (res')
{-# LINE 49 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
clockNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (T.Text) -> IO ((Ptr ()))
clockNewWithLabel' 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
clockNewWithLabel''_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = id res} in
return (res')
{-# LINE 50 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
clockNewWithClockType' :: (CUChar) -> (Int) -> (Int) -> (Int) -> (Int) -> (T.Text) -> IO ((Ptr ()))
clockNewWithClockType' a1 a2 a3 a4 a5 a6 =
let {a1' = id a1} in
let {a2' = fromIntegral a2} in
let {a3' = fromIntegral a3} in
let {a4' = fromIntegral a4} in
let {a5' = fromIntegral a5} in
let {a6' = unsafeToCString a6} in
clockNewWithClockType''_ a1' a2' a3' a4' a5' a6' >>= \res ->
let {res' = id res} in
return (res')
{-# LINE 51 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
clockNew :: Rectangle -> Maybe T.Text -> IO (Ref Clock)
clockNew rectangle l' =
let (x_pos, y_pos, width, height) = fromRectangle rectangle
in case l' of
Nothing -> clockNew' x_pos y_pos width height >>=
toRef
Just l -> clockNewWithLabel' x_pos y_pos width height l >>=
toRef
clockNewWithType :: ClockType -> Rectangle -> T.Text -> IO (Ref Clock)
clockNewWithType clocktype' rectangle' label' =
let (x_pos, y_pos, width, height) = fromRectangle rectangle'
in
clockNewWithClockType' (castCharToCUChar . chr . fromEnum $ clocktype') x_pos y_pos width height label' >>= toRef
setValueWithhms' :: (Ptr ()) -> (Int) -> (Int) -> (Int) -> IO ()
setValueWithhms' a1 a2 a3 a4 =
let {a1' = id a1} in
let {a2' = fromIntegral a2} in
let {a3' = fromIntegral a3} in
let {a4' = fromIntegral a4} in
setValueWithhms''_ a1' a2' a3' a4' >>
return ()
{-# LINE 66 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
setValue' :: (Ptr ()) -> (CULong) -> IO ()
setValue' a1 a2 =
let {a1' = id a1} in
let {a2' = id a2} in
setValue''_ a1' a2' >>
return ()
{-# LINE 67 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
instance (impl ~ (ClockSetTimeType -> IO ())) => Op (SetValue()) Clock orig impl where
runOp _ _ clock' clockvalue = withRef clock' $ \clockPtr ->
case clockvalue of
ClockSetByTime (ClockByTime (Hour h)(Minute m) (Second s)) -> setValueWithhms' clockPtr h m s
ClockSetSinceEpoch (ClockSinceEpoch (Second s)) -> setValue' clockPtr (fromIntegral s)
getValue' :: (Ptr ()) -> IO ((CULong))
getValue' a1 =
let {a1' = id a1} in
getValue''_ a1' >>= \res ->
let {res' = id res} in
return (res')
{-# LINE 74 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
instance (impl ~ (IO ClockSinceEpoch)) => Op (GetValueSinceEpoch ()) Clock orig impl where
runOp _ _ clock' = withRef clock' $ \clockPtr ->
getValue' clockPtr >>= return . ClockSinceEpoch . Second . fromIntegral
clockHour' :: (Ptr ()) -> IO ((Int))
clockHour' a1 =
let {a1' = id a1} in
clockHour''_ a1' >>= \res ->
let {res' = fromIntegral res} in
return (res')
{-# LINE 79 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
clockMinute' :: (Ptr ()) -> IO ((Int))
clockMinute' a1 =
let {a1' = id a1} in
clockMinute''_ a1' >>= \res ->
let {res' = fromIntegral res} in
return (res')
{-# LINE 80 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
clockSecond' :: (Ptr ()) -> IO ((Int))
clockSecond' a1 =
let {a1' = id a1} in
clockSecond''_ a1' >>= \res ->
let {res' = fromIntegral res} in
return (res')
{-# LINE 81 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
instance (impl ~ (IO ClockByTime)) => Op (GetValue ()) Clock orig impl where
runOp _ _ clock' = withRef clock' $ \clockPtr -> do
hour' <- clockHour' clockPtr
minute' <- clockMinute' clockPtr
second' <- clockSecond' clockPtr
return $ ClockByTime (Hour hour') (Minute minute') (Second second')
menu_Handle' :: (Ptr ()) -> (CInt) -> IO ((Int))
menu_Handle' a1 a2 =
let {a1' = id a1} in
let {a2' = id a2} in
menu_Handle''_ a1' a2' >>= \res ->
let {res' = fromIntegral res} in
return (res')
{-# LINE 89 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
instance (impl ~ (Event -> IO (Either UnknownEvent ()))) => Op (Handle ()) Clock orig impl where
runOp _ _ menu_ event = withRef menu_ (\p -> menu_Handle' p (fromIntegral . fromEnum $ event)) >>= return . successOrUnknownEvent
setType' :: (Ptr ()) -> (Word8) -> IO ()
setType' a1 a2 =
let {a1' = id a1} in
let {a2' = fromIntegral a2} in
setType''_ a1' a2' >>
return ()
{-# LINE 93 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
instance (impl ~ (ClockType -> IO ())) => Op (SetType ()) Clock orig impl where
runOp _ _ clock type'' = withRef clock $ \clockPtr -> setType' clockPtr (fromIntegral (fromEnum type''))
type' :: (Ptr ()) -> IO ((Word8))
type' a1 =
let {a1' = id a1} in
type''_ a1' >>= \res ->
let {res' = fromIntegral res} in
return (res')
{-# LINE 97 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
instance (impl ~ ( IO (ClockType))) => Op (GetType_ ()) Clock orig impl where
runOp _ _ clock = withRef clock $ \clockPtr -> type' clockPtr >>= return . toEnum . fromIntegral
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_New"
clockNew''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO (C2HSImp.Ptr ()))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_New_WithLabel"
clockNewWithLabel''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO (C2HSImp.Ptr ())))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_New_WithClockType"
clockNewWithClockType''_ :: (C2HSImp.CUChar -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO (C2HSImp.Ptr ()))))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_set_value_with_hms"
setValueWithhms''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO ())))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_set_value"
setValue''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CULong -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_value"
getValue''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CULong))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_hour"
clockHour''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_minute"
clockMinute''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_second"
clockSecond''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_handle"
menu_Handle''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_set_type"
setType''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CUChar -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_type"
type''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CUChar))