#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Gdk.Structs.RGBA
(
RGBA(..) ,
newZeroRGBA ,
noRGBA ,
#if ENABLE_OVERLOADING
RGBACopyMethodInfo ,
#endif
rGBACopy ,
#if ENABLE_OVERLOADING
RGBAEqualMethodInfo ,
#endif
rGBAEqual ,
#if ENABLE_OVERLOADING
RGBAFreeMethodInfo ,
#endif
rGBAFree ,
#if ENABLE_OVERLOADING
RGBAHashMethodInfo ,
#endif
rGBAHash ,
#if ENABLE_OVERLOADING
RGBAParseMethodInfo ,
#endif
rGBAParse ,
#if ENABLE_OVERLOADING
RGBAToStringMethodInfo ,
#endif
rGBAToString ,
getRGBAAlpha ,
#if ENABLE_OVERLOADING
rGBA_alpha ,
#endif
setRGBAAlpha ,
getRGBABlue ,
#if ENABLE_OVERLOADING
rGBA_blue ,
#endif
setRGBABlue ,
getRGBAGreen ,
#if ENABLE_OVERLOADING
rGBA_green ,
#endif
setRGBAGreen ,
getRGBARed ,
#if ENABLE_OVERLOADING
rGBA_red ,
#endif
setRGBARed ,
) where
import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P
import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
newtype RGBA = RGBA (ManagedPtr RGBA)
foreign import ccall "gdk_rgba_get_type" c_gdk_rgba_get_type ::
IO GType
instance BoxedObject RGBA where
boxedType _ = c_gdk_rgba_get_type
newZeroRGBA :: MonadIO m => m RGBA
newZeroRGBA = liftIO $ callocBoxedBytes 32 >>= wrapBoxed RGBA
instance tag ~ 'AttrSet => Constructible RGBA tag where
new _ attrs = do
o <- newZeroRGBA
GI.Attributes.set o attrs
return o
noRGBA :: Maybe RGBA
noRGBA = Nothing
getRGBARed :: MonadIO m => RGBA -> m Double
getRGBARed s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO CDouble
let val' = realToFrac val
return val'
setRGBARed :: MonadIO m => RGBA -> Double -> m ()
setRGBARed s val = liftIO $ withManagedPtr s $ \ptr -> do
let val' = realToFrac val
poke (ptr `plusPtr` 0) (val' :: CDouble)
#if ENABLE_OVERLOADING
data RGBARedFieldInfo
instance AttrInfo RGBARedFieldInfo where
type AttrAllowedOps RGBARedFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint RGBARedFieldInfo = (~) Double
type AttrBaseTypeConstraint RGBARedFieldInfo = (~) RGBA
type AttrGetType RGBARedFieldInfo = Double
type AttrLabel RGBARedFieldInfo = "red"
type AttrOrigin RGBARedFieldInfo = RGBA
attrGet _ = getRGBARed
attrSet _ = setRGBARed
attrConstruct = undefined
attrClear _ = undefined
rGBA_red :: AttrLabelProxy "red"
rGBA_red = AttrLabelProxy
#endif
getRGBAGreen :: MonadIO m => RGBA -> m Double
getRGBAGreen s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO CDouble
let val' = realToFrac val
return val'
setRGBAGreen :: MonadIO m => RGBA -> Double -> m ()
setRGBAGreen s val = liftIO $ withManagedPtr s $ \ptr -> do
let val' = realToFrac val
poke (ptr `plusPtr` 8) (val' :: CDouble)
#if ENABLE_OVERLOADING
data RGBAGreenFieldInfo
instance AttrInfo RGBAGreenFieldInfo where
type AttrAllowedOps RGBAGreenFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint RGBAGreenFieldInfo = (~) Double
type AttrBaseTypeConstraint RGBAGreenFieldInfo = (~) RGBA
type AttrGetType RGBAGreenFieldInfo = Double
type AttrLabel RGBAGreenFieldInfo = "green"
type AttrOrigin RGBAGreenFieldInfo = RGBA
attrGet _ = getRGBAGreen
attrSet _ = setRGBAGreen
attrConstruct = undefined
attrClear _ = undefined
rGBA_green :: AttrLabelProxy "green"
rGBA_green = AttrLabelProxy
#endif
getRGBABlue :: MonadIO m => RGBA -> m Double
getRGBABlue s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 16) :: IO CDouble
let val' = realToFrac val
return val'
setRGBABlue :: MonadIO m => RGBA -> Double -> m ()
setRGBABlue s val = liftIO $ withManagedPtr s $ \ptr -> do
let val' = realToFrac val
poke (ptr `plusPtr` 16) (val' :: CDouble)
#if ENABLE_OVERLOADING
data RGBABlueFieldInfo
instance AttrInfo RGBABlueFieldInfo where
type AttrAllowedOps RGBABlueFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint RGBABlueFieldInfo = (~) Double
type AttrBaseTypeConstraint RGBABlueFieldInfo = (~) RGBA
type AttrGetType RGBABlueFieldInfo = Double
type AttrLabel RGBABlueFieldInfo = "blue"
type AttrOrigin RGBABlueFieldInfo = RGBA
attrGet _ = getRGBABlue
attrSet _ = setRGBABlue
attrConstruct = undefined
attrClear _ = undefined
rGBA_blue :: AttrLabelProxy "blue"
rGBA_blue = AttrLabelProxy
#endif
getRGBAAlpha :: MonadIO m => RGBA -> m Double
getRGBAAlpha s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 24) :: IO CDouble
let val' = realToFrac val
return val'
setRGBAAlpha :: MonadIO m => RGBA -> Double -> m ()
setRGBAAlpha s val = liftIO $ withManagedPtr s $ \ptr -> do
let val' = realToFrac val
poke (ptr `plusPtr` 24) (val' :: CDouble)
#if ENABLE_OVERLOADING
data RGBAAlphaFieldInfo
instance AttrInfo RGBAAlphaFieldInfo where
type AttrAllowedOps RGBAAlphaFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint RGBAAlphaFieldInfo = (~) Double
type AttrBaseTypeConstraint RGBAAlphaFieldInfo = (~) RGBA
type AttrGetType RGBAAlphaFieldInfo = Double
type AttrLabel RGBAAlphaFieldInfo = "alpha"
type AttrOrigin RGBAAlphaFieldInfo = RGBA
attrGet _ = getRGBAAlpha
attrSet _ = setRGBAAlpha
attrConstruct = undefined
attrClear _ = undefined
rGBA_alpha :: AttrLabelProxy "alpha"
rGBA_alpha = AttrLabelProxy
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList RGBA
type instance O.AttributeList RGBA = RGBAAttributeList
type RGBAAttributeList = ('[ '("red", RGBARedFieldInfo), '("green", RGBAGreenFieldInfo), '("blue", RGBABlueFieldInfo), '("alpha", RGBAAlphaFieldInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "gdk_rgba_copy" gdk_rgba_copy ::
Ptr RGBA ->
IO (Ptr RGBA)
rGBACopy ::
(B.CallStack.HasCallStack, MonadIO m) =>
RGBA
-> m RGBA
rGBACopy rgba = liftIO $ do
rgba' <- unsafeManagedPtrGetPtr rgba
result <- gdk_rgba_copy rgba'
checkUnexpectedReturnNULL "rGBACopy" result
result' <- (wrapBoxed RGBA) result
touchManagedPtr rgba
return result'
#if ENABLE_OVERLOADING
data RGBACopyMethodInfo
instance (signature ~ (m RGBA), MonadIO m) => O.MethodInfo RGBACopyMethodInfo RGBA signature where
overloadedMethod _ = rGBACopy
#endif
foreign import ccall "gdk_rgba_equal" gdk_rgba_equal ::
Ptr RGBA ->
Ptr RGBA ->
IO CInt
rGBAEqual ::
(B.CallStack.HasCallStack, MonadIO m) =>
RGBA
-> RGBA
-> m Bool
rGBAEqual p1 p2 = liftIO $ do
p1' <- unsafeManagedPtrGetPtr p1
p2' <- unsafeManagedPtrGetPtr p2
result <- gdk_rgba_equal p1' p2'
let result' = (/= 0) result
touchManagedPtr p1
touchManagedPtr p2
return result'
#if ENABLE_OVERLOADING
data RGBAEqualMethodInfo
instance (signature ~ (RGBA -> m Bool), MonadIO m) => O.MethodInfo RGBAEqualMethodInfo RGBA signature where
overloadedMethod _ = rGBAEqual
#endif
foreign import ccall "gdk_rgba_free" gdk_rgba_free ::
Ptr RGBA ->
IO ()
rGBAFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
RGBA
-> m ()
rGBAFree rgba = liftIO $ do
rgba' <- unsafeManagedPtrGetPtr rgba
gdk_rgba_free rgba'
touchManagedPtr rgba
return ()
#if ENABLE_OVERLOADING
data RGBAFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RGBAFreeMethodInfo RGBA signature where
overloadedMethod _ = rGBAFree
#endif
foreign import ccall "gdk_rgba_hash" gdk_rgba_hash ::
Ptr RGBA ->
IO Word32
rGBAHash ::
(B.CallStack.HasCallStack, MonadIO m) =>
RGBA
-> m Word32
rGBAHash p = liftIO $ do
p' <- unsafeManagedPtrGetPtr p
result <- gdk_rgba_hash p'
touchManagedPtr p
return result
#if ENABLE_OVERLOADING
data RGBAHashMethodInfo
instance (signature ~ (m Word32), MonadIO m) => O.MethodInfo RGBAHashMethodInfo RGBA signature where
overloadedMethod _ = rGBAHash
#endif
foreign import ccall "gdk_rgba_parse" gdk_rgba_parse ::
Ptr RGBA ->
CString ->
IO CInt
rGBAParse ::
(B.CallStack.HasCallStack, MonadIO m) =>
RGBA
-> T.Text
-> m Bool
rGBAParse rgba spec = liftIO $ do
rgba' <- unsafeManagedPtrGetPtr rgba
spec' <- textToCString spec
result <- gdk_rgba_parse rgba' spec'
let result' = (/= 0) result
touchManagedPtr rgba
freeMem spec'
return result'
#if ENABLE_OVERLOADING
data RGBAParseMethodInfo
instance (signature ~ (T.Text -> m Bool), MonadIO m) => O.MethodInfo RGBAParseMethodInfo RGBA signature where
overloadedMethod _ = rGBAParse
#endif
foreign import ccall "gdk_rgba_to_string" gdk_rgba_to_string ::
Ptr RGBA ->
IO CString
rGBAToString ::
(B.CallStack.HasCallStack, MonadIO m) =>
RGBA
-> m T.Text
rGBAToString rgba = liftIO $ do
rgba' <- unsafeManagedPtrGetPtr rgba
result <- gdk_rgba_to_string rgba'
checkUnexpectedReturnNULL "rGBAToString" result
result' <- cstringToText result
freeMem result
touchManagedPtr rgba
return result'
#if ENABLE_OVERLOADING
data RGBAToStringMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo RGBAToStringMethodInfo RGBA signature where
overloadedMethod _ = rGBAToString
#endif
#if ENABLE_OVERLOADING
type family ResolveRGBAMethod (t :: Symbol) (o :: *) :: * where
ResolveRGBAMethod "copy" o = RGBACopyMethodInfo
ResolveRGBAMethod "equal" o = RGBAEqualMethodInfo
ResolveRGBAMethod "free" o = RGBAFreeMethodInfo
ResolveRGBAMethod "hash" o = RGBAHashMethodInfo
ResolveRGBAMethod "parse" o = RGBAParseMethodInfo
ResolveRGBAMethod "toString" o = RGBAToStringMethodInfo
ResolveRGBAMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveRGBAMethod t RGBA, O.MethodInfo info RGBA p) => O.IsLabelProxy t (RGBA -> p) where
fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveRGBAMethod t RGBA, O.MethodInfo info RGBA p) => O.IsLabel t (RGBA -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif
#endif