-- GENERATED by C->Haskell Compiler, version 0.28.1 Switcheroo, 1 April 2016 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "src/Graphics/UI/FLTK/LowLevel/Scrollbar.chs" #-}
{-# LANGUAGE CPP, ExistentialQuantification, TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses, FlexibleContexts, ScopedTypeVariables #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Graphics.UI.FLTK.LowLevel.Scrollbar
    (
     -- * Constructor
     scrollbarNew,
     -- * Hierarchy
     --
     -- $hierarchy

     -- * Functions
     --
     -- $functions
    )
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

scrollbarNew' :: (Int) -> (Int) -> (Int) -> (Int) -> IO ((Ptr ()))
scrollbarNew' a1 a2 a3 a4 =
  let {a1' = fromIntegral a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = fromIntegral a4} in 
  scrollbarNew''_ a1' a2' a3' a4' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 29 "src/Graphics/UI/FLTK/LowLevel/Scrollbar.chs" #-}

scrollbarNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (T.Text) -> IO ((Ptr ()))
scrollbarNewWithLabel' 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 
  scrollbarNewWithLabel''_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 30 "src/Graphics/UI/FLTK/LowLevel/Scrollbar.chs" #-}

scrollbarNew :: Rectangle -> Maybe T.Text -> IO (Ref Scrollbar)
scrollbarNew rectangle l'=
    let (x_pos, y_pos, width, height) = fromRectangle rectangle
    in case l' of
        Nothing -> scrollbarNew' x_pos y_pos width height >>=
                             toRef
        Just l -> scrollbarNewWithLabel' x_pos y_pos width height l >>=
                               toRef

scrollbarDestroy' :: (Ptr ()) -> IO ((()))
scrollbarDestroy' a1 =
  let {a1' = id a1} in 
  scrollbarDestroy''_ a1' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')

{-# LINE 40 "src/Graphics/UI/FLTK/LowLevel/Scrollbar.chs" #-}

instance (impl ~ (IO ())) => Op (Destroy ()) Scrollbar orig impl where
  runOp _ _ win = swapRef win $ \winPtr -> do
    scrollbarDestroy' winPtr
    return nullPtr

scrollvalue' :: (Ptr ()) -> (Int) -> (Int) -> (Int) -> (Int) -> IO ((Int))
scrollvalue' 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 
  scrollvalue''_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 46 "src/Graphics/UI/FLTK/LowLevel/Scrollbar.chs" #-}

instance (impl ~ (Int -> Int -> Int -> Int ->  IO (Int))) => Op (SetScrollValue ()) Scrollbar orig impl where
  runOp _ _ slider pos size first total = withRef slider $ \sliderPtr -> scrollvalue' sliderPtr pos size first total

setLinesize' :: (Ptr ()) -> (Int) -> IO ()
setLinesize' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  setLinesize''_ a1' a2' >>
  return ()

{-# LINE 50 "src/Graphics/UI/FLTK/LowLevel/Scrollbar.chs" #-}

instance (impl ~ (LineSize ->  IO ())) => Op (SetLinesize ()) Scrollbar orig impl where
  runOp _ _ slider (LineSize i) = withRef slider $ \sliderPtr -> setLinesize' sliderPtr i

linesize' :: (Ptr ()) -> IO ((Int))
linesize' a1 =
  let {a1' = id a1} in 
  linesize''_ a1' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 54 "src/Graphics/UI/FLTK/LowLevel/Scrollbar.chs" #-}

instance (impl ~ ( IO LineSize)) => Op (GetLinesize ()) Scrollbar orig impl where
  runOp _ _ slider = withRef slider $ \sliderPtr -> linesize' sliderPtr >>= return . LineSize

scrollbarHandle' :: (Ptr ()) -> (CInt) -> IO ((Int))
scrollbarHandle' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  scrollbarHandle''_ a1' a2' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 59 "src/Graphics/UI/FLTK/LowLevel/Scrollbar.chs" #-}

instance (impl ~ (Event -> IO (Either UnknownEvent ()))) => Op (Handle ()) Scrollbar orig impl where
  runOp _ _ scrollbar event = withRef scrollbar (\p -> scrollbarHandle' 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' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')

{-# LINE 63 "src/Graphics/UI/FLTK/LowLevel/Scrollbar.chs" #-}

instance (impl ~ (ScrollbarType ->  IO ())) => Op (SetType ()) Scrollbar 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 66 "src/Graphics/UI/FLTK/LowLevel/Scrollbar.chs" #-}

instance (impl ~ IO (ScrollbarType)) => Op (GetType_ ()) Scrollbar orig impl where
  runOp _ _ widget = withRef widget $ \widgetPtr -> type' widgetPtr >>= return . toEnum . fromInteger . toInteger

-- $functions
-- @
-- destroy :: 'Ref' 'Scrollbar' -> 'IO' ()
--
-- getLinesize :: 'Ref' 'Scrollbar' -> 'IO' 'LineSize'
--
-- getType_ :: 'Ref' 'Scrollbar' -> 'IO' ('ScrollbarType')
--
-- handle :: 'Ref' 'Scrollbar' -> ('Event' -> 'IO' ('Either' 'UnknownEvent' ()))
--
-- setLinesize :: 'Ref' 'Scrollbar' -> 'LineSize' -> 'IO' ()
--
-- setScrollValue :: 'Ref' 'Scrollbar' -> 'Int' -> 'Int' -> 'Int' -> 'Int' -> 'IO' ('Int')
--
-- setType :: 'Ref' 'Scrollbar' -> 'ScrollbarType' -> 'IO' ()
-- @

-- $hierarchy
-- @
-- "Graphics.UI.FLTK.LowLevel.Widget"
--  |
--  v
-- "Graphics.UI.FLTK.LowLevel.Valuator"
--  |
--  v
-- "Graphics.UI.FLTK.LowLevel.Slider"
--  |
--  v
-- "Graphics.UI.FLTK.LowLevel.Scrollbar"
-- @

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Scrollbar.chs.h Fl_Scrollbar_New"
  scrollbarNew''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO (C2HSImp.Ptr ()))))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Scrollbar.chs.h Fl_Scrollbar_New_WithLabel"
  scrollbarNewWithLabel''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO (C2HSImp.Ptr ())))))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Scrollbar.chs.h Fl_Scrollbar_Destroy"
  scrollbarDestroy''_ :: ((C2HSImp.Ptr ()) -> (IO ()))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Scrollbar.chs.h Fl_Scrollbar_scrollvalue"
  scrollvalue''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO C2HSImp.CInt))))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Scrollbar.chs.h Fl_Scrollbar_set_linesize"
  setLinesize''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO ())))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Scrollbar.chs.h Fl_Scrollbar_linesize"
  linesize''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Scrollbar.chs.h Fl_Scrollbar_handle"
  scrollbarHandle''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Scrollbar.chs.h Fl_Widget_set_type"
  setType''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CUChar -> (IO ())))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Scrollbar.chs.h Fl_Widget_type"
  type''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CUChar))