module Graphics.UI.FLTK.LowLevel.Output
(
FlOutputType(..),
outputNew
)
where
import C2HS hiding (cFromEnum, cFromBool, cToBool,cToEnum)
import Foreign.C.Types
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 FlOutputType = FlNormalOutput
| FlMultilineOutput
instance Enum FlOutputType where
succ FlNormalOutput = FlMultilineOutput
succ FlMultilineOutput = error "FlOutputType.succ: FlMultilineOutput has no successor"
pred FlMultilineOutput = FlNormalOutput
pred FlNormalOutput = error "FlOutputType.pred: FlNormalOutput 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 FlMultilineOutput
fromEnum FlNormalOutput = 8
fromEnum FlMultilineOutput = 12
toEnum 8 = FlNormalOutput
toEnum 12 = FlMultilineOutput
toEnum unmatched = error ("FlOutputType.toEnum: Cannot match " ++ show unmatched)
outputNew' :: (Int) -> (Int) -> (Int) -> (Int) -> IO ((Ptr ()))
outputNew' a1 a2 a3 a4 =
let {a1' = fromIntegral a1} in
let {a2' = fromIntegral a2} in
let {a3' = fromIntegral a3} in
let {a4' = fromIntegral a4} in
outputNew''_ a1' a2' a3' a4' >>= \res ->
let {res' = id res} in
return (res')
outputNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (String) -> IO ((Ptr ()))
outputNewWithLabel' 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
outputNewWithLabel''_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = id res} in
return (res')
multilineOutputNew' :: (Int) -> (Int) -> (Int) -> (Int) -> IO ((Ptr ()))
multilineOutputNew' a1 a2 a3 a4 =
let {a1' = fromIntegral a1} in
let {a2' = fromIntegral a2} in
let {a3' = fromIntegral a3} in
let {a4' = fromIntegral a4} in
multilineOutputNew''_ a1' a2' a3' a4' >>= \res ->
let {res' = id res} in
return (res')
multilineOutputNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (String) -> IO ((Ptr ()))
multilineOutputNewWithLabel' 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
multilineOutputNewWithLabel''_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = id res} in
return (res')
outputNew :: Rectangle -> Maybe String -> Maybe FlOutputType -> IO (Ref Output)
outputNew rectangle l' flOutputType =
let (x_pos, y_pos, width, height) = fromRectangle rectangle
constructor = case flOutputType of
Just FlNormalOutput -> maybe outputNew' (\l -> (\x y w h -> outputNewWithLabel' x y w h l)) l'
Just FlMultilineOutput -> maybe multilineOutputNew' (\l -> (\x y w h -> multilineOutputNewWithLabel' x y w h l)) l'
Nothing -> outputNew'
in
constructor x_pos y_pos width height >>= toRef
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 ~ (FlOutputType -> IO ())) => Op (SetType ()) Output orig impl where
runOp _ _ widget t = withRef widget $ \widgetPtr -> setType' widgetPtr (fromInteger $ toInteger $ fromEnum t)
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Output.chs.h Fl_Output_New"
outputNew''_ :: (CInt -> (CInt -> (CInt -> (CInt -> (IO (Ptr ()))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Output.chs.h Fl_Output_New_WithLabel"
outputNewWithLabel''_ :: (CInt -> (CInt -> (CInt -> (CInt -> ((Ptr CChar) -> (IO (Ptr ())))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Output.chs.h Fl_Multiline_Output_New"
multilineOutputNew''_ :: (CInt -> (CInt -> (CInt -> (CInt -> (IO (Ptr ()))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Output.chs.h Fl_Multiline_Output_New_WithLabel"
multilineOutputNewWithLabel''_ :: (CInt -> (CInt -> (CInt -> (CInt -> ((Ptr CChar) -> (IO (Ptr ())))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Output.chs.h Fl_Widget_set_type"
setType''_ :: ((Ptr ()) -> (CUChar -> (IO ())))