-- GENERATED by C->Haskell Compiler, version 0.18.2 The shapeless maps, 31 Oct 2014 (Haskell)
-- Edit the ORIGNAL .chs file instead!


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

    )
where



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

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

{-# LINE 24 "src/Graphics/UI/FLTK/LowLevel/Counter.chs" #-}

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

{-# LINE 25 "src/Graphics/UI/FLTK/LowLevel/Counter.chs" #-}

counterNew :: Rectangle -> Maybe String -> IO (Ref Counter)
counterNew rectangle l'=
    let (x_pos, y_pos, width, height) = fromRectangle rectangle
    in case l' of
        Nothing -> counterNew' x_pos y_pos width height >>=
                             toRef
        Just l -> counterNewWithLabel' x_pos y_pos width height l >>=
                               toRef

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

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

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

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

{-# LINE 41 "src/Graphics/UI/FLTK/LowLevel/Counter.chs" #-}

instance (impl ~ (Event -> IO Int)) => Op (Handle ()) Counter orig impl where
  runOp _ _ counter event = withRef counter (\p -> counterHandle' p (fromIntegral . fromEnum $ event))
lstep' :: (Ptr ()) -> (Double) -> IO ()
lstep' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = realToFrac a2} in 
  lstep''_ a1' a2' >>
  return ()

{-# LINE 44 "src/Graphics/UI/FLTK/LowLevel/Counter.chs" #-}

instance (impl ~ (Double ->  IO ())) => Op (SetLstep ()) Counter orig impl where
  runOp _ _ counter lstep = withRef counter $ \counterPtr -> lstep' counterPtr lstep
setTextfont' :: (Ptr ()) -> (Font) -> IO ()
setTextfont' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = cFromFont a2} in 
  setTextfont''_ a1' a2' >>
  return ()

{-# LINE 47 "src/Graphics/UI/FLTK/LowLevel/Counter.chs" #-}

instance (impl ~ (Font ->  IO ())) => Op (SetTextfont ()) Counter orig impl where
  runOp _ _ counter text = withRef counter $ \counterPtr -> setTextfont' counterPtr text
textfont' :: (Ptr ()) -> IO ((Font))
textfont' a1 =
  let {a1' = id a1} in 
  textfont''_ a1' >>= \res ->
  let {res' = cToFont res} in
  return (res')

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

instance (impl ~ ( IO (Font))) => Op (GetTextfont ()) Counter orig impl where
  runOp _ _ counter = withRef counter $ \counterPtr -> textfont' counterPtr
setTextsize' :: (Ptr ()) -> (CInt) -> IO ()
setTextsize' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  setTextsize''_ a1' a2' >>
  return ()

{-# LINE 53 "src/Graphics/UI/FLTK/LowLevel/Counter.chs" #-}

instance (impl ~ (FontSize ->  IO ())) => Op (SetTextsize ()) Counter orig impl where
  runOp _ _ counter (FontSize text) = withRef counter $ \counterPtr -> setTextsize' counterPtr text
textsize' :: (Ptr ()) -> IO ((CInt))
textsize' a1 =
  let {a1' = id a1} in 
  textsize''_ a1' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 56 "src/Graphics/UI/FLTK/LowLevel/Counter.chs" #-}

instance (impl ~ ( IO (FontSize))) => Op (GetTextsize ()) Counter orig impl where
  runOp _ _ counter = withRef counter $ \counterPtr -> textsize' counterPtr >>= return . FontSize
setTextcolor' :: (Ptr ()) -> (Color) -> IO ()
setTextcolor' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = cFromColor a2} in 
  setTextcolor''_ a1' a2' >>
  return ()

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

instance (impl ~ (Color ->  IO ())) => Op (SetTextcolor ()) Counter orig impl where
  runOp _ _ counter text = withRef counter $ \counterPtr -> setTextcolor' counterPtr text
textcolor' :: (Ptr ()) -> IO ((Color))
textcolor' a1 =
  let {a1' = id a1} in 
  textcolor''_ a1' >>= \res ->
  let {res' = cToColor res} in
  return (res')

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

instance (impl ~ ( IO (Color))) => Op (GetTextcolor ()) Counter orig impl where
  runOp _ _ counter = withRef counter $ \counterPtr -> textcolor' counterPtr

-- $Counterfunctions
--
-- @
-- destroy :: 'Ref' 'Counter' -> 'IO' ()
--
-- getTextcolor :: 'Ref' 'Counter' -> 'IO' 'Color'
--
-- getTextfont :: 'Ref' 'Counter' -> 'IO' 'Font'
--
-- getTextsize :: 'Ref' 'Counter' -> 'IO' 'FontSize'
--
-- handle :: 'Ref' 'Counter' -> 'Event' -> 'IO' 'Int'
--
-- setLstep :: 'Ref' 'Counter' -> 'Double' -> 'IO' ()
--
-- setTextcolor :: 'Ref' 'Counter' -> 'Color' -> 'IO' ()
--
-- setTextfont :: 'Ref' 'Counter' -> 'Font' -> 'IO' ()
--
-- setTextsize :: 'Ref' 'Counter' -> 'FontSize' -> 'IO' ()
--
-- @

-- $hierarchy
-- @
-- "Graphics.UI.FLTK.LowLevel.Widget"
--  |
--  v
-- "Graphics.UI.FLTK.LowLevel.Valuator"
--  |
--  v
-- "Graphics.UI.FLTK.LowLevel.Counter"
-- @
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Counter.chs.h Fl_Counter_New"
  counterNew''_ :: (CInt -> (CInt -> (CInt -> (CInt -> (IO (Ptr ()))))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Counter.chs.h Fl_Counter_New_WithLabel"
  counterNewWithLabel''_ :: (CInt -> (CInt -> (CInt -> (CInt -> ((Ptr CChar) -> (IO (Ptr ())))))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Counter.chs.h Fl_Counter_Destroy"
  counterDestroy''_ :: ((Ptr ()) -> (IO ()))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Counter.chs.h Fl_Counter_handle"
  counterHandle''_ :: ((Ptr ()) -> (CInt -> (IO CInt)))

foreign import ccall unsafe "Graphics/UI/FLTK/LowLevel/Counter.chs.h Fl_Counter_lstep"
  lstep''_ :: ((Ptr ()) -> (CDouble -> (IO ())))

foreign import ccall unsafe "Graphics/UI/FLTK/LowLevel/Counter.chs.h Fl_Counter_set_textfont"
  setTextfont''_ :: ((Ptr ()) -> (CInt -> (IO ())))

foreign import ccall unsafe "Graphics/UI/FLTK/LowLevel/Counter.chs.h Fl_Counter_textfont"
  textfont''_ :: ((Ptr ()) -> (IO CInt))

foreign import ccall unsafe "Graphics/UI/FLTK/LowLevel/Counter.chs.h Fl_Counter_set_textsize"
  setTextsize''_ :: ((Ptr ()) -> (CInt -> (IO ())))

foreign import ccall unsafe "Graphics/UI/FLTK/LowLevel/Counter.chs.h Fl_Counter_textsize"
  textsize''_ :: ((Ptr ()) -> (IO CInt))

foreign import ccall unsafe "Graphics/UI/FLTK/LowLevel/Counter.chs.h Fl_Counter_set_textcolor"
  setTextcolor''_ :: ((Ptr ()) -> (CUInt -> (IO ())))

foreign import ccall unsafe "Graphics/UI/FLTK/LowLevel/Counter.chs.h Fl_Counter_textcolor"
  textcolor''_ :: ((Ptr ()) -> (IO CUInt))