-- 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/Box.chs" #-}
{-# LANGUAGE CPP, TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses, FlexibleContexts #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Graphics.UI.FLTK.LowLevel.Box
    (
     -- * Constructor
     boxNew,
     boxNewWithBoxtype,
     boxCustom,
     boxCustomWithBoxtype
     -- * 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.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 Graphics.UI.FLTK.LowLevel.Base.Widget

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

{-# LINE 32 "src/Graphics/UI/FLTK/LowLevel/Box.chs" #-}

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

{-# LINE 33 "src/Graphics/UI/FLTK/LowLevel/Box.chs" #-}

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

{-# LINE 34 "src/Graphics/UI/FLTK/LowLevel/Box.chs" #-}

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

{-# LINE 35 "src/Graphics/UI/FLTK/LowLevel/Box.chs" #-}

boxNewWithBoxtype' :: (Boxtype) -> (Int) -> (Int) -> (Int) -> (Int) -> (CString) -> IO ((Ptr ()))
boxNewWithBoxtype' a1 a2 a3 a4 a5 a6 =
  let {a1' = cFromEnum a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = fromIntegral a4} in 
  let {a5' = fromIntegral a5} in 
  (flip ($)) a6 $ \a6' -> 
  boxNewWithBoxtype''_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 36 "src/Graphics/UI/FLTK/LowLevel/Box.chs" #-}

overriddenBoxNewWithBoxtype' :: (Boxtype) -> (Int) -> (Int) -> (Int) -> (Int) -> (CString) -> (Ptr ()) -> IO ((Ptr ()))
overriddenBoxNewWithBoxtype' a1 a2 a3 a4 a5 a6 a7 =
  let {a1' = cFromEnum a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = fromIntegral a4} in 
  let {a5' = fromIntegral a5} in 
  (flip ($)) a6 $ \a6' -> 
  let {a7' = id a7} in 
  overriddenBoxNewWithBoxtype''_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 37 "src/Graphics/UI/FLTK/LowLevel/Box.chs" #-}


boxCustom :: Rectangle                     -- ^ The bounds of this box
          -> Maybe T.Text                  -- ^ Optional label
          -> Maybe (Ref Box -> IO ())      -- ^ Optional custom box drawing function
          -> Maybe (CustomWidgetFuncs Box) -- ^ Optional widget overrides
          -> IO (Ref Box)
boxCustom rectangle l' draw' funcs' =
  widgetMaker
    rectangle
    l'
    draw'
    funcs'
    overriddenBoxNew'
    overriddenBoxNewWithLabel'

boxCustomWithBoxtype :: Boxtype -> Rectangle -> T.Text -> Maybe (Ref Box -> IO ()) -> Maybe (CustomWidgetFuncs Box) -> IO (Ref Box)
boxCustomWithBoxtype :: Boxtype
-> Rectangle
-> Text
-> Maybe (Ref Box -> IO ())
-> Maybe (CustomWidgetFuncs Box)
-> IO (Ref Box)
boxCustomWithBoxtype boxtype' :: Boxtype
boxtype' rectangle' :: Rectangle
rectangle' l' :: Text
l' draw' :: Maybe (Ref Box -> IO ())
draw' funcs' :: Maybe (CustomWidgetFuncs Box)
funcs' =
    let (x_pos :: Int
x_pos, y_pos :: Int
y_pos, width :: Int
width, height :: Int
height) = Rectangle -> (Int, Int, Int, Int)
fromRectangle Rectangle
rectangle'
    in case Maybe (CustomWidgetFuncs Box)
funcs' of
        Just fs :: CustomWidgetFuncs Box
fs -> do
          Ptr ()
ptr <- Maybe (Ref Box -> IO ()) -> CustomWidgetFuncs Box -> IO (Ptr ())
forall a.
Parent a WidgetBase =>
Maybe (Ref a -> IO ()) -> CustomWidgetFuncs a -> IO (Ptr ())
customWidgetFunctionStruct Maybe (Ref Box -> IO ())
draw' CustomWidgetFuncs Box
fs
          Ref Box
ref <- Text -> IO CString
copyTextToCString Text
l' IO CString -> (CString -> IO (Ref Box)) -> IO (Ref Box)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \l'' :: CString
l'' -> Boxtype
-> Int -> Int -> Int -> Int -> CString -> Ptr () -> IO (Ptr ())
overriddenBoxNewWithBoxtype' Boxtype
boxtype' Int
x_pos Int
y_pos Int
width Int
height CString
l'' (Ptr () -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr ()
ptr) IO (Ptr ()) -> (Ptr () -> IO (Ref Box)) -> IO (Ref Box)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Ptr () -> IO (Ref Box)
forall a. Ptr () -> IO (Ref a)
toRef
          Ref Box -> WidgetFlag -> IO ()
forall r a impl.
(HasCallStack, Match r ~ FindOp a a (SetFlag ()),
 Op (SetFlag ()) r a impl) =>
Ref a -> impl
setFlag Ref Box
ref WidgetFlag
WidgetFlagCopiedLabel
          Ref Box -> WidgetFlag -> IO ()
forall r a impl.
(HasCallStack, Match r ~ FindOp a a (SetFlag ()),
 Op (SetFlag ()) r a impl) =>
Ref a -> impl
setFlag Ref Box
ref WidgetFlag
WidgetFlagCopiedTooltip
          Ref Box -> IO (Ref Box)
forall (m :: * -> *) a. Monad m => a -> m a
return Ref Box
ref
        Nothing ->
          Text -> IO CString
copyTextToCString Text
l' IO CString -> (CString -> IO (Ref Box)) -> IO (Ref Box)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \l'' :: CString
l'' -> Boxtype -> Int -> Int -> Int -> Int -> CString -> IO (Ptr ())
boxNewWithBoxtype' Boxtype
boxtype' Int
x_pos Int
y_pos Int
width Int
height CString
l'' IO (Ptr ()) -> (Ptr () -> IO (Ref Box)) -> IO (Ref Box)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Ptr () -> IO (Ref Box)
forall a. Ptr () -> IO (Ref a)
toRef


boxNew :: Rectangle -> Maybe T.Text -> IO (Ref Box)
boxNew :: Rectangle -> Maybe Text -> IO (Ref Box)
boxNew rectangle :: Rectangle
rectangle l' :: Maybe Text
l' =
  Rectangle
-> Maybe Text
-> Maybe (Ref Box -> IO ())
-> Maybe (CustomWidgetFuncs Box)
-> (Int -> Int -> Int -> Int -> Ptr () -> IO (Ptr ()))
-> (Int -> Int -> Int -> Int -> CString -> Ptr () -> IO (Ptr ()))
-> IO (Ref Box)
forall a.
Parent a WidgetBase =>
Rectangle
-> Maybe Text
-> Maybe (Ref a -> IO ())
-> Maybe (CustomWidgetFuncs a)
-> (Int -> Int -> Int -> Int -> Ptr () -> IO (Ptr ()))
-> (Int -> Int -> Int -> Int -> CString -> Ptr () -> IO (Ptr ()))
-> IO (Ref a)
widgetMaker
    Rectangle
rectangle
    Maybe Text
l'
    Maybe (Ref Box -> IO ())
forall a. Maybe a
Nothing
    Maybe (CustomWidgetFuncs Box)
forall a. Maybe a
Nothing
    Int -> Int -> Int -> Int -> Ptr () -> IO (Ptr ())
overriddenBoxNew'
    Int -> Int -> Int -> Int -> CString -> Ptr () -> IO (Ptr ())
overriddenBoxNewWithLabel'

boxNewWithBoxtype :: Boxtype -> Rectangle -> T.Text -> IO (Ref Box)
boxNewWithBoxtype :: Boxtype -> Rectangle -> Text -> IO (Ref Box)
boxNewWithBoxtype boxtype' :: Boxtype
boxtype' rectangle' :: Rectangle
rectangle' l' :: Text
l' =
    let (x_pos :: Int
x_pos, y_pos :: Int
y_pos, width :: Int
width, height :: Int
height) = Rectangle -> (Int, Int, Int, Int)
fromRectangle Rectangle
rectangle'
    in do
      Ref Box
ref <- Text -> IO CString
copyTextToCString Text
l' IO CString -> (CString -> IO (Ref Box)) -> IO (Ref Box)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \l'' :: CString
l'' -> Boxtype -> Int -> Int -> Int -> Int -> CString -> IO (Ptr ())
boxNewWithBoxtype' Boxtype
boxtype' Int
x_pos Int
y_pos Int
width Int
height CString
l'' IO (Ptr ()) -> (Ptr () -> IO (Ref Box)) -> IO (Ref Box)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Ptr () -> IO (Ref Box)
forall a. Ptr () -> IO (Ref a)
toRef
      Ref Box -> WidgetFlag -> IO ()
forall r a impl.
(HasCallStack, Match r ~ FindOp a a (SetFlag ()),
 Op (SetFlag ()) r a impl) =>
Ref a -> impl
setFlag Ref Box
ref WidgetFlag
WidgetFlagCopiedLabel
      Ref Box -> WidgetFlag -> IO ()
forall r a impl.
(HasCallStack, Match r ~ FindOp a a (SetFlag ()),
 Op (SetFlag ()) r a impl) =>
Ref a -> impl
setFlag Ref Box
ref WidgetFlag
WidgetFlagCopiedTooltip
      Ref Box -> IO (Ref Box)
forall (m :: * -> *) a. Monad m => a -> m a
return Ref Box
ref

boxHandle' :: (Ptr ()) -> (CInt) -> IO ((Int))
boxHandle' :: Ptr () -> CInt -> IO Int
boxHandle' a1 :: Ptr ()
a1 a2 :: CInt
a2 =
  let {a1' = id a1} in 
  let {a2' :: CInt
a2' = CInt -> CInt
forall a. a -> a
id CInt
a2} in 
  Ptr () -> CInt -> IO CInt
boxHandle''_ Ptr ()
a1' CInt
a2' 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 86 "src/Graphics/UI/FLTK/LowLevel/Box.chs" #-}

instance (impl ~ (Event -> IO (Either UnknownEvent ()))) => Op (Handle ()) Box orig impl where
  runOp _ _ box event = withRef box (\p -> boxHandle' p (fromIntegral . fromEnum $ event)) >>= return  . successOrUnknownEvent


-- $functions
-- @
-- handle :: 'Ref' 'Box' -> 'Event' -> 'IO' ('Either' 'UnknownEvent' ())
-- @

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

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

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

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Box.chs.h Fl_OverriddenBox_New_WithLabel"
  overriddenBoxNewWithLabel''_ :: (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/Box.chs.h Fl_OverriddenBox_New"
  overriddenBoxNew''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr ()) -> (IO (C2HSImp.Ptr ())))))))

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

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Box.chs.h Fl_OverriddenBox_New_WithBoxtype"
  overriddenBoxNewWithBoxtype''_ :: (C2HSImp.CInt -> (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/Box.chs.h Fl_Box_handle"
  boxHandle''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))