gi-gdk-0.3.16.12: GI/Gdk/Structs/Color.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
A #GdkColor is used to describe a color,
similar to the XColor struct used in the X11 drawing API.
-}
module GI.Gdk.Structs.Color
(
-- * Exported types
Color(..) ,
noColor ,
-- * Methods
-- ** colorCopy
colorCopy ,
-- ** colorEqual
colorEqual ,
-- ** colorFree
colorFree ,
-- ** colorHash
colorHash ,
-- ** colorToString
colorToString ,
-- * Properties
-- ** Blue
colorReadBlue ,
-- ** Green
colorReadGreen ,
-- ** Pixel
colorReadPixel ,
-- ** Red
colorReadRed ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.Gdk.Types
import GI.Gdk.Callbacks
newtype Color = Color (ForeignPtr Color)
foreign import ccall "gdk_color_get_type" c_gdk_color_get_type ::
IO GType
instance BoxedObject Color where
boxedType _ = c_gdk_color_get_type
noColor :: Maybe Color
noColor = Nothing
colorReadPixel :: Color -> IO Word32
colorReadPixel s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO Word32
return val
colorReadRed :: Color -> IO Word16
colorReadRed s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 4) :: IO Word16
return val
colorReadGreen :: Color -> IO Word16
colorReadGreen s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 6) :: IO Word16
return val
colorReadBlue :: Color -> IO Word16
colorReadBlue s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO Word16
return val
-- method Color::copy
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Color", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Color", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "Color"
-- throws : False
-- Skip return : False
foreign import ccall "gdk_color_copy" gdk_color_copy ::
Ptr Color -> -- _obj : TInterface "Gdk" "Color"
IO (Ptr Color)
{-# DEPRECATED colorCopy ["(Since version 3.14)","Use #GdkRGBA"]#-}
colorCopy ::
(MonadIO m) =>
Color -> -- _obj
m Color
colorCopy _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- gdk_color_copy _obj'
checkUnexpectedReturnNULL "gdk_color_copy" result
result' <- (wrapBoxed Color) result
touchManagedPtr _obj
return result'
-- method Color::equal
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Color", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "colorb", argType = TInterface "Gdk" "Color", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Color", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "colorb", argType = TInterface "Gdk" "Color", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False
foreign import ccall "gdk_color_equal" gdk_color_equal ::
Ptr Color -> -- _obj : TInterface "Gdk" "Color"
Ptr Color -> -- colorb : TInterface "Gdk" "Color"
IO CInt
{-# DEPRECATED colorEqual ["(Since version 3.14)","Use #GdkRGBA"]#-}
colorEqual ::
(MonadIO m) =>
Color -> -- _obj
Color -> -- colorb
m Bool
colorEqual _obj colorb = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
let colorb' = unsafeManagedPtrGetPtr colorb
result <- gdk_color_equal _obj' colorb'
let result' = (/= 0) result
touchManagedPtr _obj
touchManagedPtr colorb
return result'
-- method Color::free
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Color", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Color", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "gdk_color_free" gdk_color_free ::
Ptr Color -> -- _obj : TInterface "Gdk" "Color"
IO ()
{-# DEPRECATED colorFree ["(Since version 3.14)","Use #GdkRGBA"]#-}
colorFree ::
(MonadIO m) =>
Color -> -- _obj
m ()
colorFree _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
gdk_color_free _obj'
touchManagedPtr _obj
return ()
-- method Color::hash
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Color", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Color", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False
foreign import ccall "gdk_color_hash" gdk_color_hash ::
Ptr Color -> -- _obj : TInterface "Gdk" "Color"
IO Word32
{-# DEPRECATED colorHash ["(Since version 3.14)","Use #GdkRGBA"]#-}
colorHash ::
(MonadIO m) =>
Color -> -- _obj
m Word32
colorHash _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- gdk_color_hash _obj'
touchManagedPtr _obj
return result
-- method Color::to_string
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Color", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Color", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False
foreign import ccall "gdk_color_to_string" gdk_color_to_string ::
Ptr Color -> -- _obj : TInterface "Gdk" "Color"
IO CString
{-# DEPRECATED colorToString ["(Since version 3.14)","Use #GdkRGBA"]#-}
colorToString ::
(MonadIO m) =>
Color -> -- _obj
m T.Text
colorToString _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- gdk_color_to_string _obj'
checkUnexpectedReturnNULL "gdk_color_to_string" result
result' <- cstringToText result
freeMem result
touchManagedPtr _obj
return result'