-- 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/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.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) -> (T.Text) -> 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 
  let {a5' = unsafeToCString a5} in 
  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) -> (T.Text) -> (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 
  let {a5' = unsafeToCString a5} in 
  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) -> (T.Text) -> 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 
  let {a6' = unsafeToCString a6} in 
  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) -> (T.Text) -> (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 
  let {a6' = unsafeToCString a6} in 
  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' l' draw' funcs' =
    let (x_pos, y_pos, width, height) = fromRectangle rectangle'
    in case funcs' of
        Just fs -> do
          ptr <- customWidgetFunctionStruct draw' fs
          overriddenBoxNewWithBoxtype' boxtype' x_pos y_pos width height l' (castPtr ptr) >>= toRef
        Nothing ->
          boxNewWithBoxtype' boxtype' x_pos y_pos width height l' >>= toRef


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

boxNewWithBoxtype :: Boxtype -> Rectangle -> T.Text -> IO (Ref Box)
boxNewWithBoxtype boxtype' rectangle' l' =
    let (x_pos, y_pos, width, height) = fromRectangle rectangle'
    in
    boxNewWithBoxtype' boxtype' x_pos y_pos width height l' >>=
                             toRef

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

{-# LINE 80 "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.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)))