-- GENERATED by C->Haskell Compiler, version 0.28.6 Switcheroo, 25 November 2017 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}
{-# LANGUAGE CPP, TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses, FlexibleContexts #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Graphics.UI.FLTK.LowLevel.Base.Pack
  (
    PackType(..),
    packNew,
    packCustom
  , drawPackBase
  , handlePackBase
  , resizePackBase
  , hidePackBase
  , showWidgetPackBase
    -- * 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 Graphics.UI.FLTK.LowLevel.Fl_Enumerations
import Graphics.UI.FLTK.LowLevel.Base.Widget
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
overriddenWidgetNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (CString) -> (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 
  (flip ($)) a5 ((CString -> IO (Ptr ())) -> IO (Ptr ()))
-> (CString -> IO (Ptr ())) -> IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ \a5' :: CString
a5' -> 
  let {a6' :: Ptr ()
a6' = Ptr () -> Ptr ()
forall a. a -> a
id Ptr ()
a6} in 
  CInt -> CInt -> CInt -> CInt -> CString -> Ptr () -> IO (Ptr ())
overriddenWidgetNewWithLabel''_ CInt
a1' CInt
a2' CInt
a3' CInt
a4' CString
a5' a6' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 33 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.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 34 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

packCustom ::
       Rectangle                         -- ^ The bounds of this Pack
    -> Maybe T.Text                      -- ^ The Pack label
    -> Maybe (Ref Pack -> IO ())           -- ^ Optional custom drawing function
    -> Maybe (CustomWidgetFuncs Pack)      -- ^ Optional custom widget functions
    -> IO (Ref Pack)
packCustom rectangle l' draw' funcs' =
  widgetMaker
    rectangle
    l'
    draw'
    funcs'
    overriddenWidgetNew'
    overriddenWidgetNewWithLabel'

packNew' :: (Int) -> (Int) -> (Int) -> (Int) -> IO ((Ptr ()))
packNew' :: Int -> Int -> Int -> Int -> IO (Ptr ())
packNew' a1 :: Int
a1 a2 :: Int
a2 a3 :: Int
a3 a4 :: Int
a4 =
  let {a1' :: CInt
a1' = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a1} in 
  let {a2' :: CInt
a2' = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2} in 
  let {a3' :: CInt
a3' = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in 
  let {a4' :: CInt
a4' = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a4} in 
  CInt -> CInt -> CInt -> CInt -> IO (Ptr ())
packNew''_ CInt
a1' CInt
a2' CInt
a3' CInt
a4' IO (Ptr ()) -> (Ptr () -> IO (Ptr ())) -> IO (Ptr ())
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \res :: Ptr ()
res ->
  let {res' :: Ptr ()
res' = Ptr () -> Ptr ()
forall a. a -> a
id Ptr ()
res} in
  Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr ()
res')

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

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

{-# LINE 51 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

packNew :: Rectangle -> Maybe T.Text -> IO (Ref Pack)
packNew rectangle l' =
  widgetMaker
    rectangle
    l'
    Nothing
    Nothing
    overriddenWidgetNew'
    overriddenWidgetNewWithLabel'

getSpacing' :: (Ptr ()) -> IO ((Int))
getSpacing' :: Ptr () -> IO Int
getSpacing' a1 :: Ptr ()
a1 =
  let {a1' = id a1} in 
  Ptr () -> IO CInt
getSpacing''_ Ptr ()
a1' IO CInt -> (CInt -> IO Int) -> IO Int
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \res :: CInt
res ->
  let {res' :: Int
res' = CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
res} in
  Int -> IO Int
forall (m :: * -> *) a. Monad m => a -> m a
return (Int
res')

{-# LINE 62 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

instance (impl ~ (IO (Int))) => Op (GetSpacing ()) PackBase orig impl where
   runOp _ _ p = withRef p $ \pPtr -> getSpacing' pPtr
setSpacing' :: (Ptr ()) -> (Int) -> IO ()
setSpacing' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  setSpacing''_ a1' a2' >>
  return ()

{-# LINE 65 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

instance (impl ~ (Int ->  IO ())) => Op (SetSpacing ()) PackBase orig impl where
   runOp _ _ p pixels = withRef p $ \pPtr -> setSpacing' pPtr pixels
horizontal' :: (Ptr ()) -> IO ((Word8))
horizontal' a1 =
  let {a1' = id a1} in 
  horizontal''_ a1' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 68 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

instance (impl ~ ( IO Bool)) => Op (IsHorizontal ()) PackBase orig impl where
   runOp _ _ p = withRef p $ \pPtr -> do
     orientation <- horizontal' pPtr >>= return . cToEnum
     case orientation of
       PackHorizontal -> return True
       _  -> return False
type' :: (Ptr ()) -> IO ((Word8))
type' :: Ptr () -> IO Word8
type' a1 :: Ptr ()
a1 =
  let {a1' = id a1} in 
  Ptr () -> IO CUChar
type''_ Ptr ()
a1' IO CUChar -> (CUChar -> IO Word8) -> IO Word8
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \res :: CUChar
res ->
  let {res' :: Word8
res' = CUChar -> Word8
forall a b. (Integral a, Num b) => a -> b
fromIntegral CUChar
res} in
  Word8 -> IO Word8
forall (m :: * -> *) a. Monad m => a -> m a
return (Word8
res')

{-# LINE 75 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

instance (impl ~ ( IO (PackType))) => Op (GetType_ ()) PackBase orig impl where
   runOp _ _ widget = withRef widget $ \widgetPtr -> type' widgetPtr >>= return . cToEnum
setType' :: (Ptr ()) -> (Word8) -> IO ()
setType' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  setType''_ a1' a2' >>
  return ()

{-# LINE 78 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

instance (impl ~ (PackType ->  IO ())) => Op (SetType ()) PackBase orig impl where
   runOp _ _ widget t = withRef widget $ \widgetPtr -> setType' widgetPtr (cFromEnum t)

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

{-# LINE 82 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

drawPackBase ::  Ref PackBase -> IO ()
drawPackBase pack = withRef pack $ \packPtr -> drawSuper' packPtr
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 85 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

handlePackBase :: Ref PackBase -> Event ->  IO (Either UnknownEvent ())
handlePackBase pack event = withRef pack $ \packPtr -> handleSuper' packPtr (fromIntegral (fromEnum event)) >>= return . successOrUnknownEvent
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 88 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

resizePackBase :: Ref PackBase -> Rectangle -> IO ()
resizePackBase pack rectangle =
    let (x_pos, y_pos, width, height) = fromRectangle rectangle
    in withRef pack $ \packPtr -> resizeSuper' packPtr x_pos y_pos width height
hideSuper' :: (Ptr ()) -> IO ((()))
hideSuper' a1 =
  let {a1' = id a1} in 
  hideSuper''_ a1' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')

{-# LINE 93 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

hidePackBase ::  Ref PackBase -> IO ()
hidePackBase pack = withRef pack $ \packPtr -> hideSuper' packPtr
showSuper' :: (Ptr ()) -> IO ((()))
showSuper' a1 =
  let {a1' = id a1} in 
  showSuper''_ a1' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')

{-# LINE 96 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

showWidgetPackBase ::  Ref PackBase -> IO ()
showWidgetPackBase pack = withRef pack $ \packPtr -> showSuper' packPtr

draw'' :: (Ptr ()) -> IO ()
draw'' a1 =
  let {a1' = id a1} in 
  draw'''_ a1' >>
  return ()

{-# LINE 100 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

instance (impl ~ (  IO ())) => Op (Draw ()) PackBase orig impl where
  runOp _ _ pack = withRef pack $ \packPtr -> draw'' packPtr
packHandle' :: (Ptr ()) -> (CInt) -> IO ((Int))
packHandle' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  packHandle''_ a1' a2' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 103 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

instance (impl ~ (Event -> IO (Either UnknownEvent ()))) => Op (Handle ()) PackBase orig impl where
  runOp _ _ pack event = withRef pack (\p -> packHandle' p (fromIntegral . fromEnum $ event)) >>= return  . successOrUnknownEvent
show' :: (Ptr ()) -> IO ()
show' a1 =
  let {a1' = id a1} in 
  show''_ a1' >>
  return ()

{-# LINE 106 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

instance (impl ~ (  IO ())) => Op (ShowWidget ()) PackBase orig impl where
  runOp _ _ pack = withRef pack $ \packPtr -> show' packPtr
hide' :: (Ptr ()) -> IO ()
hide' a1 =
  let {a1' = id a1} in 
  hide''_ a1' >>
  return ()

{-# LINE 109 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

instance (impl ~ (  IO ())) => Op (Hide ()) PackBase orig impl where
  runOp _ _ pack = withRef pack $ \packPtr -> hide' packPtr
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 112 "src/Graphics/UI/FLTK/LowLevel/Base/Pack.chs" #-}

instance (impl ~ (Rectangle -> IO ())) => Op (Resize ()) PackBase orig impl where
  runOp _ _ pack rectangle = withRef pack $ \packPtr -> do
                                 let (x_pos,y_pos,w_pos,h_pos) = fromRectangle rectangle
                                 resize' packPtr x_pos y_pos w_pos h_pos


-- $hierarchy
-- @
-- "Graphics.UI.FLTK.LowLevel.Base.Widget"
--  |
--  v
-- "Graphics.UI.FLTK.LowLevel.Base.Group"
--  |
--  v
-- "Graphics.UI.FLTK.LowLevel.Base.Pack"
-- @

-- $functions
-- @
-- draw :: 'Ref' 'PackBase' -> 'IO' ()
--
-- getSpacing :: 'Ref' 'PackBase' -> 'IO' ('Int')
--
-- getType_ :: 'Ref' 'PackBase' -> 'IO' ('PackType')
--
-- handle :: 'Ref' 'PackBase' -> 'Event' -> 'IO' ('Either' 'UnknownEvent' ())
--
-- hide :: 'Ref' 'PackBase' -> 'IO' ()
--
-- isHorizontal :: 'Ref' 'PackBase' -> 'IO' 'Bool'
--
-- resize :: 'Ref' 'PackBase' -> 'Rectangle' -> 'IO' ()
--
-- setSpacing :: 'Ref' 'PackBase' -> 'Int' -> 'IO' ()
--
-- setType :: 'Ref' 'PackBase' -> 'PackType' -> 'IO' ()
--
-- showWidget :: 'Ref' 'PackBase' -> 'IO' ()
-- @

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/Pack.chs.h Fl_OverriddenPack_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/Base/Pack.chs.h Fl_OverriddenPack_New"
  overriddenWidgetNew''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr ()) -> (IO (C2HSImp.Ptr ())))))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/Pack.chs.h Fl_Pack_New"
  packNew''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO (C2HSImp.Ptr ()))))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/Pack.chs.h Fl_Pack_New_WithLabel"
  packNewWithLabel''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO (C2HSImp.Ptr ())))))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/Pack.chs.h Fl_Pack_get_spacing"
  getSpacing''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/Pack.chs.h Fl_Pack_set_spacing"
  setSpacing''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO ())))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/Pack.chs.h Fl_Pack_horizontal"
  horizontal''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CUChar))

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

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

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/Pack.chs.h Fl_Pack_draw_super"
  drawSuper''_ :: ((C2HSImp.Ptr ()) -> (IO ()))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/Pack.chs.h Fl_Pack_handle_super"
  handleSuper''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/Pack.chs.h Fl_Pack_resize_super"
  resizeSuper''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO ()))))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/Pack.chs.h Fl_Pack_hide_super"
  hideSuper''_ :: ((C2HSImp.Ptr ()) -> (IO ()))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/Pack.chs.h Fl_Pack_show_super"
  showSuper''_ :: ((C2HSImp.Ptr ()) -> (IO ()))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/Pack.chs.h Fl_Pack_draw"
  draw'''_ :: ((C2HSImp.Ptr ()) -> (IO ()))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/Pack.chs.h Fl_Pack_handle"
  packHandle''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/Pack.chs.h Fl_Pack_show"
  show''_ :: ((C2HSImp.Ptr ()) -> (IO ()))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/Pack.chs.h Fl_Pack_hide"
  hide''_ :: ((C2HSImp.Ptr ()) -> (IO ()))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/Pack.chs.h Fl_Pack_resize"
  resize''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO ()))))))