{-# 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,
clockCustom,
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 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
import Graphics.UI.FLTK.LowLevel.Widget
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 44 "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
overriddenWidgetNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (T.Text) -> (Ptr ()) -> IO ((Ptr ()))
overriddenWidgetNewWithLabel' a1 a2 a3 a4 a5 a6 =
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
let {a6' = id a6} in
overriddenWidgetNewWithLabel''_ a1' a2' a3' a4' a5' a6' >>= \res ->
let {res' = id res} in
return (res')
{-# LINE 52 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
overriddenWidgetNew' :: (Int) -> (Int) -> (Int) -> (Int) -> (Ptr ()) -> IO ((Ptr ()))
overriddenWidgetNew' 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' = id a5} in
overriddenWidgetNew''_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = id res} in
return (res')
{-# LINE 53 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
clockCustom ::
Rectangle
-> Maybe T.Text
-> Maybe (Ref Clock -> IO ())
-> Maybe (CustomWidgetFuncs Clock)
-> IO (Ref Clock)
clockCustom rectangle l' draw' funcs' =
widgetMaker
rectangle
l'
draw'
funcs'
overriddenWidgetNew'
overriddenWidgetNewWithLabel'
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 71 "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 72 "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 73 "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 88 "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 89 "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 96 "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 101 "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 102 "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 103 "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')
setType' :: (Ptr ()) -> (Word8) -> IO ()
setType' a1 a2 =
let {a1' = id a1} in
let {a2' = fromIntegral a2} in
setType''_ a1' a2' >>
return ()
{-# LINE 111 "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 115 "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
draw'' :: (Ptr ()) -> IO ()
draw'' a1 =
let {a1' = id a1} in
draw'''_ a1' >>
return ()
{-# LINE 118 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
instance (impl ~ ( IO ())) => Op (Draw ()) Clock orig impl where
runOp _ _ clock = withRef clock $ \clockPtr -> draw'' clockPtr
drawSuper' :: (Ptr ()) -> IO ((()))
drawSuper' a1 =
let {a1' = id a1} in
drawSuper''_ a1' >>= \res ->
let {res' = supressWarningAboutRes res} in
return (res')
{-# LINE 121 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
instance (impl ~ ( IO ())) => Op (DrawSuper ()) Clock orig impl where
runOp _ _ clock = withRef clock $ \clockPtr -> drawSuper' clockPtr
clockHandle' :: (Ptr ()) -> (CInt) -> IO ((Int))
clockHandle' a1 a2 =
let {a1' = id a1} in
let {a2' = id a2} in
clockHandle''_ a1' a2' >>= \res ->
let {res' = fromIntegral res} in
return (res')
{-# LINE 124 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
instance (impl ~ (Event -> IO (Either UnknownEvent ()))) => Op (Handle ()) Clock orig impl where
runOp _ _ clock event = withRef clock (\p -> clockHandle' p (fromIntegral . fromEnum $ event)) >>= return . successOrUnknownEvent
handleSuper' :: (Ptr ()) -> (Int) -> IO ((Int))
handleSuper' a1 a2 =
let {a1' = id a1} in
let {a2' = fromIntegral a2} in
handleSuper''_ a1' a2' >>= \res ->
let {res' = fromIntegral res} in
return (res')
{-# LINE 127 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
instance (impl ~ (Event -> IO (Either UnknownEvent ()))) => Op (HandleSuper ()) Clock orig impl where
runOp _ _ clock event = withRef clock $ \clockPtr -> handleSuper' clockPtr (fromIntegral (fromEnum event)) >>= return . successOrUnknownEvent
resize' :: (Ptr ()) -> (Int) -> (Int) -> (Int) -> (Int) -> IO ((()))
resize' a1 a2 a3 a4 a5 =
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
resize''_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = supressWarningAboutRes res} in
return (res')
{-# LINE 130 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
instance (impl ~ (Rectangle -> IO ())) => Op (Resize ()) Clock orig impl where
runOp _ _ clock rectangle = withRef clock $ \clockPtr -> do
let (x_pos,y_pos,w_pos,h_pos) = fromRectangle rectangle
resize' clockPtr x_pos y_pos w_pos h_pos
resizeSuper' :: (Ptr ()) -> (Int) -> (Int) -> (Int) -> (Int) -> IO ((()))
resizeSuper' a1 a2 a3 a4 a5 =
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
resizeSuper''_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = supressWarningAboutRes res} in
return (res')
{-# LINE 135 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
instance (impl ~ (Rectangle -> IO ())) => Op (ResizeSuper ()) Clock orig impl where
runOp _ _ clock rectangle =
let (x_pos, y_pos, width, height) = fromRectangle rectangle
in withRef clock $ \clockPtr -> resizeSuper' clockPtr x_pos y_pos width height
hide' :: (Ptr ()) -> IO ()
hide' a1 =
let {a1' = id a1} in
hide''_ a1' >>
return ()
{-# LINE 140 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
instance (impl ~ ( IO ())) => Op (Hide ()) Clock orig impl where
runOp _ _ clock = withRef clock $ \clockPtr -> hide' clockPtr
hideSuper' :: (Ptr ()) -> IO ((()))
hideSuper' a1 =
let {a1' = id a1} in
hideSuper''_ a1' >>= \res ->
let {res' = supressWarningAboutRes res} in
return (res')
{-# LINE 143 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
instance (impl ~ ( IO ())) => Op (HideSuper ()) Clock orig impl where
runOp _ _ clock = withRef clock $ \clockPtr -> hideSuper' clockPtr
show' :: (Ptr ()) -> IO ()
show' a1 =
let {a1' = id a1} in
show''_ a1' >>
return ()
{-# LINE 146 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
instance (impl ~ ( IO ())) => Op (ShowWidget ()) Clock orig impl where
runOp _ _ clock = withRef clock $ \clockPtr -> show' clockPtr
showSuper' :: (Ptr ()) -> IO ((()))
showSuper' a1 =
let {a1' = id a1} in
showSuper''_ a1' >>= \res ->
let {res' = supressWarningAboutRes res} in
return (res')
{-# LINE 149 "src/Graphics/UI/FLTK/LowLevel/Clock.chs" #-}
instance (impl ~ ( IO ())) => Op (ShowWidgetSuper ()) Clock orig impl where
runOp _ _ clock = withRef clock $ \clockPtr -> showSuper' clockPtr
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_OverriddenClock_New_WithLabel"
overriddenWidgetNewWithLabel''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr ()) -> (IO (C2HSImp.Ptr ()))))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_OverriddenClock_New"
overriddenWidgetNew''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr ()) -> (IO (C2HSImp.Ptr ())))))))
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_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))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_draw"
draw'''_ :: ((C2HSImp.Ptr ()) -> (IO ()))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_draw_super"
drawSuper''_ :: ((C2HSImp.Ptr ()) -> (IO ()))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_handle"
clockHandle''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_handle_super"
handleSuper''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_resize"
resize''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO ()))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_resize_super"
resizeSuper''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO ()))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_hide"
hide''_ :: ((C2HSImp.Ptr ()) -> (IO ()))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_hide_super"
hideSuper''_ :: ((C2HSImp.Ptr ()) -> (IO ()))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_show"
show''_ :: ((C2HSImp.Ptr ()) -> (IO ()))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Clock.chs.h Fl_Clock_show_super"
showSuper''_ :: ((C2HSImp.Ptr ()) -> (IO ()))