-- 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/Tile.chs" #-}
{-# LANGUAGE CPP, RankNTypes, UndecidableInstances, GADTs, TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses, FlexibleContexts, ScopedTypeVariables #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Graphics.UI.FLTK.LowLevel.Tile
    (
     -- * Constructor
     tileNew,
     -- * 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

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

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

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

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

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

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 40 "src/Graphics/UI/FLTK/LowLevel/Tile.chs" #-}

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

setPosition' :: (Ptr ()) -> (Int) -> (Int) -> (Int) -> (Int) -> IO ()
setPosition' 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 
  setPosition''_ a1' a2' a3' a4' a5' >>
  return ()

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

instance (impl ~ (Rectangle ->  IO ())) => Op (SetPosition ()) Tile orig impl where
  runOp _ _ tile rectangle = withRef tile $ \tilePtr -> do
    let (x_pos,y_pos,w_pos,h_pos) = fromRectangle rectangle
    setPosition' tilePtr x_pos y_pos w_pos h_pos

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

{-# LINE 52 "src/Graphics/UI/FLTK/LowLevel/Tile.chs" #-}

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

-- $functions
-- @
-- handle :: 'Ref' 'Tile' -> ('Event' -> 'IO' ('Either' 'UnknownEvent' ()))
--
-- resize :: 'Ref' 'Tile' -> 'Rectangle' -> 'IO' ()
--
-- setPosition :: 'Ref' 'Tile' -> 'Rectangle' -> 'IO' ()
-- @

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

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

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

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

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

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