{-# LINE 2 "./Graphics/UI/Gtk/Selectors/HSV.chs" #-}
module Graphics.UI.Gtk.Selectors.HSV (
HSV,
HSVClass,
castToHSV,
toHSV,
hsvNew,
hsvIsAdjusting,
hsvToRgb,
rgbToHsv,
hsvColor,
hsvMetrics,
hsvChanged,
hsvMove,
) where
import Control.Monad (liftM)
import System.Glib.FFI
import System.Glib.Attributes
import Graphics.UI.Gtk.General.Enums (DirectionType (..))
import Graphics.UI.Gtk.Abstract.Object (makeNewObject)
import Graphics.UI.Gtk.Signals
{-# LINE 81 "./Graphics/UI/Gtk/Selectors/HSV.chs" #-}
import Graphics.UI.Gtk.Types
{-# LINE 82 "./Graphics/UI/Gtk/Selectors/HSV.chs" #-}
{-# LINE 84 "./Graphics/UI/Gtk/Selectors/HSV.chs" #-}
hsvNew :: IO HSV
hsvNew =
makeNewObject mkHSV $
liftM (castPtr :: Ptr Widget -> Ptr HSV) $
gtk_hsv_new
{-# LINE 98 "./Graphics/UI/Gtk/Selectors/HSV.chs" #-}
hsvSetColor :: HSVClass self => self
-> (Double, Double, Double)
-> IO ()
hsvSetColor self (h, s, v) =
(\(HSV arg1) arg2 arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->gtk_hsv_set_color argPtr1 arg2 arg3 arg4)
{-# LINE 116 "./Graphics/UI/Gtk/Selectors/HSV.chs" #-}
(toHSV self)
(realToFrac h)
(realToFrac s)
(realToFrac v)
hsvGetColor :: HSVClass self => self
-> IO (Double, Double, Double)
hsvGetColor self =
alloca $ \hPtr ->
alloca $ \sPtr ->
alloca $ \vPtr -> do
(\(HSV arg1) arg2 arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->gtk_hsv_get_color argPtr1 arg2 arg3 arg4)
{-# LINE 133 "./Graphics/UI/Gtk/Selectors/HSV.chs" #-}
(toHSV self)
hPtr
sPtr
vPtr
h <- peek hPtr
s <- peek sPtr
v <- peek vPtr
return (realToFrac h, realToFrac s, realToFrac v)
hsvSetMetrics :: HSVClass self => self
-> (Int, Int)
-> IO ()
hsvSetMetrics self (size, ringWidth) =
(\(HSV arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_hsv_set_metrics argPtr1 arg2 arg3)
{-# LINE 152 "./Graphics/UI/Gtk/Selectors/HSV.chs" #-}
(toHSV self)
(fromIntegral size)
(fromIntegral ringWidth)
hsvGetMetrics :: HSVClass self => self
-> IO (Int, Int)
hsvGetMetrics self =
alloca $ \sizePtr ->
alloca $ \ringWidthPtr -> do
(\(HSV arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_hsv_get_metrics argPtr1 arg2 arg3)
{-# LINE 166 "./Graphics/UI/Gtk/Selectors/HSV.chs" #-}
(toHSV self)
sizePtr
ringWidthPtr
size <- peek sizePtr
ringWidth <- peek ringWidthPtr
return (fromIntegral size, fromIntegral ringWidth)
hsvIsAdjusting :: HSVClass self => self
-> IO Bool
hsvIsAdjusting self =
liftM toBool $
(\(HSV arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_hsv_is_adjusting argPtr1)
{-# LINE 185 "./Graphics/UI/Gtk/Selectors/HSV.chs" #-}
(toHSV self)
hsvToRgb ::
(Double, Double, Double)
-> (Double, Double, Double)
hsvToRgb (h, s, v) =
unsafePerformIO $
alloca $ \rPtr ->
alloca $ \gPtr ->
alloca $ \bPtr -> do
gtk_hsv_to_rgb
{-# LINE 206 "./Graphics/UI/Gtk/Selectors/HSV.chs" #-}
(realToFrac h)
(realToFrac s)
(realToFrac v)
rPtr
gPtr
bPtr
r <- peek rPtr
g <- peek gPtr
b <- peek bPtr
return (realToFrac r, realToFrac g, realToFrac b)
rgbToHsv ::
(Double, Double, Double)
-> (Double, Double, Double)
rgbToHsv (r, g, b) =
unsafePerformIO $
alloca $ \hPtr ->
alloca $ \sPtr ->
alloca $ \vPtr -> do
gtk_rgb_to_hsv
{-# LINE 235 "./Graphics/UI/Gtk/Selectors/HSV.chs" #-}
(realToFrac r)
(realToFrac g)
(realToFrac b)
hPtr
sPtr
vPtr
h <- peek hPtr
s <- peek sPtr
v <- peek vPtr
return (realToFrac h, realToFrac s, realToFrac v)
hsvColor :: HSVClass self => Attr self (Double, Double, Double)
hsvColor = newAttr
hsvGetColor
hsvSetColor
hsvMetrics :: HSVClass self => Attr self (Int, Int)
hsvMetrics = newAttr
hsvGetMetrics
hsvSetMetrics
hsvChanged :: HSVClass self => Signal self (IO ())
hsvChanged = Signal (connect_NONE__NONE "changed")
hsvMove :: HSVClass self => Signal self (DirectionType -> IO ())
hsvMove = Signal (connect_ENUM__NONE "move")
foreign import ccall safe "gtk_hsv_new"
gtk_hsv_new :: (IO (Ptr Widget))
foreign import ccall safe "gtk_hsv_set_color"
gtk_hsv_set_color :: ((Ptr HSV) -> (CDouble -> (CDouble -> (CDouble -> (IO ())))))
foreign import ccall safe "gtk_hsv_get_color"
gtk_hsv_get_color :: ((Ptr HSV) -> ((Ptr CDouble) -> ((Ptr CDouble) -> ((Ptr CDouble) -> (IO ())))))
foreign import ccall safe "gtk_hsv_set_metrics"
gtk_hsv_set_metrics :: ((Ptr HSV) -> (CInt -> (CInt -> (IO ()))))
foreign import ccall safe "gtk_hsv_get_metrics"
gtk_hsv_get_metrics :: ((Ptr HSV) -> ((Ptr CInt) -> ((Ptr CInt) -> (IO ()))))
foreign import ccall safe "gtk_hsv_is_adjusting"
gtk_hsv_is_adjusting :: ((Ptr HSV) -> (IO CInt))
foreign import ccall safe "gtk_hsv_to_rgb"
gtk_hsv_to_rgb :: (CDouble -> (CDouble -> (CDouble -> ((Ptr CDouble) -> ((Ptr CDouble) -> ((Ptr CDouble) -> (IO ())))))))
foreign import ccall safe "gtk_rgb_to_hsv"
gtk_rgb_to_hsv :: (CDouble -> (CDouble -> (CDouble -> ((Ptr CDouble) -> ((Ptr CDouble) -> ((Ptr CDouble) -> (IO ())))))))