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

     -- * Widget 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.Dispatch
import Graphics.UI.FLTK.LowLevel.Hierarchy

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

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

instance (impl ~ ( IO (ColorChooserMode))) => Op (GetMode ()) ColorChooser orig impl where
  runOp _ _ color_chooser = withRef color_chooser $ \color_chooserPtr -> mode' color_chooserPtr >>= return . toEnum
setMode' :: (Ptr ()) -> (Int) -> IO ()
setMode' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  setMode''_ a1' a2' >>
  return ()

{-# LINE 27 "src/Graphics/UI/FLTK/LowLevel/ColorChooser.chs" #-}

instance (impl ~ (ColorChooserMode ->  IO ())) => Op (SetMode ()) ColorChooser orig impl where
  runOp _ _ color_chooser mode = withRef color_chooser $ \color_chooserPtr -> setMode' color_chooserPtr (fromEnum mode)
hue' :: (Ptr ()) -> IO ((Double))
hue' a1 =
  let {a1' = id a1} in 
  hue''_ a1' >>= \res ->
  let {res' = realToFrac res} in
  return (res')

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

instance (impl ~ ( IO (Either OutOfRange Between0And6))) => Op (GetHue ()) ColorChooser orig impl where
  runOp _ _ color_chooser = withRef color_chooser $ \color_chooserPtr -> do
    h'' <- hue' color_chooserPtr
    if ((h'' < 0.0) || (h'' >= 6.0))
     then return (Left OutOfRange)
     else return (Right (Between0And6 h''))
saturation' :: (Ptr ()) -> IO ((Double))
saturation' :: Ptr () -> IO Double
saturation' a1 :: Ptr ()
a1 =
  let {a1' :: Ptr ()
a1' = Ptr () -> Ptr ()
forall a. a -> a
id Ptr ()
a1} in 
  Ptr () -> IO CDouble
saturation''_ Ptr ()
a1' IO CDouble -> (CDouble -> IO Double) -> IO Double
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \res :: CDouble
res ->
  let {res' :: Double
res' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
res} in
  Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')

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

instance (impl ~ ( IO (Either OutOfRange Between0And1))) => Op (GetSaturation ()) ColorChooser orig impl where
  runOp _ _ color_chooser = withRef color_chooser $ \color_chooserPtr -> do
    s'' <- saturation' color_chooserPtr
    if ((s'' < 0.0) || (s'' > 1.0))
     then return (Left OutOfRange)
     else return (Right (Between0And1 s''))
value' :: (Ptr ()) -> IO ((Double))
value' :: Ptr () -> IO Double
value' a1 :: Ptr ()
a1 =
  let {a1' = id a1} in 
  value''_ a1' >>= \res ->
  let {res' = realToFrac res} in
  return (res')

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

instance (impl ~ ( IO (Either OutOfRange Between0And1))) => Op (GetValue ()) ColorChooser orig impl where
  runOp _ _ color_chooser = withRef color_chooser $ \color_chooserPtr -> do
    v'' <- value' color_chooserPtr
    if ((v'' < 0.0) || (v'' > 1.0))
     then return (Left OutOfRange)
     else return (Right (Between0And1 v''))
r' :: (Ptr ()) -> IO ((Double))
r' :: Ptr () -> IO Double
r' a1 :: Ptr ()
a1 =
  let {a1' :: Ptr ()
a1' = Ptr () -> Ptr ()
forall a. a -> a
id Ptr ()
a1} in 
  Ptr () -> IO CDouble
r''_ Ptr ()
a1' IO CDouble -> (CDouble -> IO Double) -> IO Double
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \res :: CDouble
res ->
  let {res' :: Double
res' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
res} in
  Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')

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

instance (impl ~ ( IO (Either OutOfRange Between0And1))) => Op (GetR ()) ColorChooser orig impl where
  runOp _ _ color_chooser = withRef color_chooser $ \color_chooserPtr -> do
    r'' <- r' color_chooserPtr
    if ((r'' < 0.0) || (r'' > 1.0))
     then return (Left OutOfRange)
     else return (Right (Between0And1 r''))
g' :: (Ptr ()) -> IO ((Double))
g' :: Ptr () -> IO Double
g' a1 :: Ptr ()
a1 =
  let {a1' :: Ptr ()
a1' = Ptr () -> Ptr ()
forall a. a -> a
id Ptr ()
a1} in 
  Ptr () -> IO CDouble
g''_ Ptr ()
a1' IO CDouble -> (CDouble -> IO Double) -> IO Double
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \res :: CDouble
res ->
  let {res' :: Double
res' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
res} in
  Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')

{-# LINE 58 "src/Graphics/UI/FLTK/LowLevel/ColorChooser.chs" #-}

instance (impl ~ ( IO (Either OutOfRange Between0And1))) => Op (GetG ()) ColorChooser orig impl where
  runOp _ _ color_chooser = withRef color_chooser $ \color_chooserPtr -> do
    g'' <- g' color_chooserPtr
    if ((g'' < 0.0) || (g'' > 1.0))
     then return (Left OutOfRange)
     else return (Right (Between0And1 g''))
b' :: (Ptr ()) -> IO ((Double))
b' :: Ptr () -> IO Double
b' a1 :: Ptr ()
a1 =
  let {a1' :: Ptr ()
a1' = Ptr () -> Ptr ()
forall a. a -> a
id Ptr ()
a1} in 
  Ptr () -> IO CDouble
b''_ Ptr ()
a1' IO CDouble -> (CDouble -> IO Double) -> IO Double
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \res :: CDouble
res ->
  let {res' :: Double
res' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
res} in
  Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')

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

instance (impl ~ ( IO (Either OutOfRange Between0And1))) => Op (GetB ()) ColorChooser orig impl where
  runOp _ _ color_chooser = withRef color_chooser $ \color_chooserPtr -> do
    b'' <- b' color_chooserPtr
    if ((b'' < 0.0) || (b'' > 1.0))
     then return (Left OutOfRange)
     else return (Right (Between0And1 b''))
hsv' :: (Ptr ()) -> (Double) -> (Double) -> (Double) -> IO ((Int))
hsv' :: Ptr () -> Double -> Double -> Double -> IO Int
hsv' a1 :: Ptr ()
a1 a2 :: Double
a2 a3 :: Double
a3 a4 :: Double
a4 =
  let {a1' = id a1} in 
  let {a2' = realToFrac a2} in 
  let {a3' = realToFrac a3} in 
  let {a4' = realToFrac a4} in 
  Ptr () -> CDouble -> CDouble -> CDouble -> IO CInt
hsv''_ Ptr ()
a1' CDouble
a2' CDouble
a3' CDouble
a4' 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 72 "src/Graphics/UI/FLTK/LowLevel/ColorChooser.chs" #-}

instance (impl ~ ((Between0And6, Between0And1, Between0And1) ->  IO (Either NoChange ()))) => Op (SetHsv ()) ColorChooser orig impl where
  runOp _ _ color_chooser (Between0And6 h'', Between0And1 s'', Between0And1 v'') =
    withRef color_chooser $ \color_chooserPtr -> do
      ret <- hsv' color_chooserPtr h'' s'' v''
      if (ret == 0) then return (Left NoChange) else return (Right ())
rgb' :: (Ptr ()) -> (Double) -> (Double) -> (Double) -> IO ((Int))
rgb' a1 a2 a3 a4 =
  let {a1' = id a1} in 
  let {a2' = realToFrac a2} in 
  let {a3' = realToFrac a3} in 
  let {a4' = realToFrac a4} in 
  rgb''_ a1' a2' a3' a4' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

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

instance (impl ~ ((Between0And1, Between0And1, Between0And1) ->  IO (Either NoChange ()))) => Op (SetRgb ()) ColorChooser orig impl where
  runOp _ _ color_chooser (Between0And1 r'', Between0And1 g'', Between0And1 b'') =
    withRef color_chooser $ \color_chooserPtr -> do
      ret <- rgb' color_chooserPtr r'' g'' b''
      if (ret == 0) then return (Left NoChange) else return (Right ())
draw' :: (Ptr ()) -> IO ()
draw' a1 =
  let {a1' = id a1} in 
  draw''_ a1' >>
  return ()

{-# LINE 84 "src/Graphics/UI/FLTK/LowLevel/ColorChooser.chs" #-}

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

{-# LINE 87 "src/Graphics/UI/FLTK/LowLevel/ColorChooser.chs" #-}

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

{-# LINE 90 "src/Graphics/UI/FLTK/LowLevel/ColorChooser.chs" #-}

instance (impl ~ (  IO ())) => Op (Hide ()) ColorChooser orig impl where
  runOp _ _ colorChooser = withRef colorChooser $ \colorChooserPtr -> hide' colorChooserPtr
show' :: (Ptr ()) -> IO ()
show' a1 =
  let {a1' = id a1} in 
  show''_ a1' >>
  return ()

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

instance (impl ~ (  IO ())) => Op (ShowWidget ()) ColorChooser orig impl where
  runOp _ _ colorChooser = withRef colorChooser $ \colorChooserPtr -> show' colorChooserPtr
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 96 "src/Graphics/UI/FLTK/LowLevel/ColorChooser.chs" #-}

instance (impl ~ (Rectangle -> IO ())) => Op (Resize ()) ColorChooser orig impl where
  runOp _ _ colorChooser rectangle = withRef colorChooser $ \colorChooserPtr -> do
                                 let (x_pos,y_pos,w_pos,h_pos) = fromRectangle rectangle
                                 resize' colorChooserPtr 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.ColorChooser"
--  |
--  v
-- "Graphics.UI.FLTK.LowLevel.ColorChooser"
-- @

-- $functions
-- @
-- draw :: 'Ref' 'ColorChooser' -> 'IO' ()
--
-- getB :: 'Ref' 'ColorChooser' -> 'IO' ('Either' 'OutOfRange' 'Between0And1')
--
-- getG :: 'Ref' 'ColorChooser' -> 'IO' ('Either' 'OutOfRange' 'Between0And1')
--
-- getHue :: 'Ref' 'ColorChooser' -> 'IO' ('Either' 'OutOfRange' 'Between0And6')
--
-- getMode :: 'Ref' 'ColorChooser' -> 'IO' ('ColorChooserMode')
--
-- getR :: 'Ref' 'ColorChooser' -> 'IO' ('Either' 'OutOfRange' 'Between0And1')
--
-- getSaturation :: 'Ref' 'ColorChooser' -> 'IO' ('Either' 'OutOfRange' 'Between0And1')
--
-- getValue :: 'Ref' 'ColorChooser' -> 'IO' ('Either' 'OutOfRange' 'Between0And1')
--
-- handle :: 'Ref' 'ColorChooser' -> 'Event' -> 'IO' ('Either' 'UnknownEvent' ())
--
-- hide :: 'Ref' 'ColorChooser' -> 'IO' ()
--
-- resize :: 'Ref' 'ColorChooser' -> 'Rectangle' -> 'IO' ()
--
-- setHsv :: 'Ref' 'ColorChooser' -> ('Between0And6', 'Between0And1', 'Between0And1') -> 'IO' ('Either' 'NoChange' ())
--
-- setMode :: 'Ref' 'ColorChooser' -> 'ColorChooserMode' -> 'IO' ()
--
-- setRgb :: 'Ref' 'ColorChooser' -> ('Between0And1', 'Between0And1', 'Between0And1') -> 'IO' ('Either' 'NoChange' ())
--
-- showWidget :: 'Ref' 'ColorChooser' -> 'IO' ()
-- @

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

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

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/ColorChooser.chs.h Fl_Color_Chooser_hue"
  hue''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CDouble))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/ColorChooser.chs.h Fl_Color_Chooser_saturation"
  saturation''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CDouble))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/ColorChooser.chs.h Fl_Color_Chooser_value"
  value''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CDouble))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/ColorChooser.chs.h Fl_Color_Chooser_r"
  r''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CDouble))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/ColorChooser.chs.h Fl_Color_Chooser_g"
  g''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CDouble))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/ColorChooser.chs.h Fl_Color_Chooser_b"
  b''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CDouble))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/ColorChooser.chs.h Fl_Color_Chooser_hsv"
  hsv''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (IO C2HSImp.CInt)))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/ColorChooser.chs.h Fl_Color_Chooser_rgb"
  rgb''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (IO C2HSImp.CInt)))))

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

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

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

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

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