{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gdk.Structs.Rectangle
(
Rectangle(..) ,
newZeroRectangle ,
noRectangle ,
#if defined(ENABLE_OVERLOADING)
ResolveRectangleMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
RectangleEqualMethodInfo ,
#endif
rectangleEqual ,
#if defined(ENABLE_OVERLOADING)
RectangleIntersectMethodInfo ,
#endif
rectangleIntersect ,
#if defined(ENABLE_OVERLOADING)
RectangleUnionMethodInfo ,
#endif
rectangleUnion ,
getRectangleHeight ,
#if defined(ENABLE_OVERLOADING)
rectangle_height ,
#endif
setRectangleHeight ,
getRectangleWidth ,
#if defined(ENABLE_OVERLOADING)
rectangle_width ,
#endif
setRectangleWidth ,
getRectangleX ,
#if defined(ENABLE_OVERLOADING)
rectangle_x ,
#endif
setRectangleX ,
getRectangleY ,
#if defined(ENABLE_OVERLOADING)
rectangle_y ,
#endif
setRectangleY ,
) 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.GClosure as B.GClosure
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.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
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
import qualified GHC.OverloadedLabels as OL
newtype Rectangle = Rectangle (ManagedPtr Rectangle)
deriving (Eq)
foreign import ccall "gdk_rectangle_get_type" c_gdk_rectangle_get_type ::
IO GType
instance BoxedObject Rectangle where
boxedType _ = c_gdk_rectangle_get_type
instance B.GValue.IsGValue Rectangle where
toGValue o = do
gtype <- c_gdk_rectangle_get_type
B.ManagedPtr.withManagedPtr o (B.GValue.buildGValue gtype B.GValue.set_boxed)
fromGValue gv = do
ptr <- B.GValue.get_boxed gv :: IO (Ptr Rectangle)
B.ManagedPtr.newBoxed Rectangle ptr
newZeroRectangle :: MonadIO m => m Rectangle
newZeroRectangle = liftIO $ callocBoxedBytes 16 >>= wrapBoxed Rectangle
instance tag ~ 'AttrSet => Constructible Rectangle tag where
new _ attrs = do
o <- newZeroRectangle
GI.Attributes.set o attrs
return o
noRectangle :: Maybe Rectangle
noRectangle = Nothing
getRectangleX :: MonadIO m => Rectangle -> m Int32
getRectangleX s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO Int32
return val
setRectangleX :: MonadIO m => Rectangle -> Int32 -> m ()
setRectangleX s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 0) (val :: Int32)
#if defined(ENABLE_OVERLOADING)
data RectangleXFieldInfo
instance AttrInfo RectangleXFieldInfo where
type AttrBaseTypeConstraint RectangleXFieldInfo = (~) Rectangle
type AttrAllowedOps RectangleXFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint RectangleXFieldInfo = (~) Int32
type AttrTransferTypeConstraint RectangleXFieldInfo = (~)Int32
type AttrTransferType RectangleXFieldInfo = Int32
type AttrGetType RectangleXFieldInfo = Int32
type AttrLabel RectangleXFieldInfo = "x"
type AttrOrigin RectangleXFieldInfo = Rectangle
attrGet = getRectangleX
attrSet = setRectangleX
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
rectangle_x :: AttrLabelProxy "x"
rectangle_x = AttrLabelProxy
#endif
getRectangleY :: MonadIO m => Rectangle -> m Int32
getRectangleY s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 4) :: IO Int32
return val
setRectangleY :: MonadIO m => Rectangle -> Int32 -> m ()
setRectangleY s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 4) (val :: Int32)
#if defined(ENABLE_OVERLOADING)
data RectangleYFieldInfo
instance AttrInfo RectangleYFieldInfo where
type AttrBaseTypeConstraint RectangleYFieldInfo = (~) Rectangle
type AttrAllowedOps RectangleYFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint RectangleYFieldInfo = (~) Int32
type AttrTransferTypeConstraint RectangleYFieldInfo = (~)Int32
type AttrTransferType RectangleYFieldInfo = Int32
type AttrGetType RectangleYFieldInfo = Int32
type AttrLabel RectangleYFieldInfo = "y"
type AttrOrigin RectangleYFieldInfo = Rectangle
attrGet = getRectangleY
attrSet = setRectangleY
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
rectangle_y :: AttrLabelProxy "y"
rectangle_y = AttrLabelProxy
#endif
getRectangleWidth :: MonadIO m => Rectangle -> m Int32
getRectangleWidth s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO Int32
return val
setRectangleWidth :: MonadIO m => Rectangle -> Int32 -> m ()
setRectangleWidth s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 8) (val :: Int32)
#if defined(ENABLE_OVERLOADING)
data RectangleWidthFieldInfo
instance AttrInfo RectangleWidthFieldInfo where
type AttrBaseTypeConstraint RectangleWidthFieldInfo = (~) Rectangle
type AttrAllowedOps RectangleWidthFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint RectangleWidthFieldInfo = (~) Int32
type AttrTransferTypeConstraint RectangleWidthFieldInfo = (~)Int32
type AttrTransferType RectangleWidthFieldInfo = Int32
type AttrGetType RectangleWidthFieldInfo = Int32
type AttrLabel RectangleWidthFieldInfo = "width"
type AttrOrigin RectangleWidthFieldInfo = Rectangle
attrGet = getRectangleWidth
attrSet = setRectangleWidth
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
rectangle_width :: AttrLabelProxy "width"
rectangle_width = AttrLabelProxy
#endif
getRectangleHeight :: MonadIO m => Rectangle -> m Int32
getRectangleHeight s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 12) :: IO Int32
return val
setRectangleHeight :: MonadIO m => Rectangle -> Int32 -> m ()
setRectangleHeight s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 12) (val :: Int32)
#if defined(ENABLE_OVERLOADING)
data RectangleHeightFieldInfo
instance AttrInfo RectangleHeightFieldInfo where
type AttrBaseTypeConstraint RectangleHeightFieldInfo = (~) Rectangle
type AttrAllowedOps RectangleHeightFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint RectangleHeightFieldInfo = (~) Int32
type AttrTransferTypeConstraint RectangleHeightFieldInfo = (~)Int32
type AttrTransferType RectangleHeightFieldInfo = Int32
type AttrGetType RectangleHeightFieldInfo = Int32
type AttrLabel RectangleHeightFieldInfo = "height"
type AttrOrigin RectangleHeightFieldInfo = Rectangle
attrGet = getRectangleHeight
attrSet = setRectangleHeight
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
rectangle_height :: AttrLabelProxy "height"
rectangle_height = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Rectangle
type instance O.AttributeList Rectangle = RectangleAttributeList
type RectangleAttributeList = ('[ '("x", RectangleXFieldInfo), '("y", RectangleYFieldInfo), '("width", RectangleWidthFieldInfo), '("height", RectangleHeightFieldInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "gdk_rectangle_equal" gdk_rectangle_equal ::
Ptr Rectangle ->
Ptr Rectangle ->
IO CInt
rectangleEqual ::
(B.CallStack.HasCallStack, MonadIO m) =>
Rectangle
-> Rectangle
-> m Bool
rectangleEqual rect1 rect2 = liftIO $ do
rect1' <- unsafeManagedPtrGetPtr rect1
rect2' <- unsafeManagedPtrGetPtr rect2
result <- gdk_rectangle_equal rect1' rect2'
let result' = (/= 0) result
touchManagedPtr rect1
touchManagedPtr rect2
return result'
#if defined(ENABLE_OVERLOADING)
data RectangleEqualMethodInfo
instance (signature ~ (Rectangle -> m Bool), MonadIO m) => O.MethodInfo RectangleEqualMethodInfo Rectangle signature where
overloadedMethod = rectangleEqual
#endif
foreign import ccall "gdk_rectangle_intersect" gdk_rectangle_intersect ::
Ptr Rectangle ->
Ptr Rectangle ->
Ptr Rectangle ->
IO CInt
rectangleIntersect ::
(B.CallStack.HasCallStack, MonadIO m) =>
Rectangle
-> Rectangle
-> m ((Bool, Rectangle))
rectangleIntersect src1 src2 = liftIO $ do
src1' <- unsafeManagedPtrGetPtr src1
src2' <- unsafeManagedPtrGetPtr src2
dest <- callocBoxedBytes 16 :: IO (Ptr Rectangle)
result <- gdk_rectangle_intersect src1' src2' dest
let result' = (/= 0) result
dest' <- (wrapBoxed Rectangle) dest
touchManagedPtr src1
touchManagedPtr src2
return (result', dest')
#if defined(ENABLE_OVERLOADING)
data RectangleIntersectMethodInfo
instance (signature ~ (Rectangle -> m ((Bool, Rectangle))), MonadIO m) => O.MethodInfo RectangleIntersectMethodInfo Rectangle signature where
overloadedMethod = rectangleIntersect
#endif
foreign import ccall "gdk_rectangle_union" gdk_rectangle_union ::
Ptr Rectangle ->
Ptr Rectangle ->
Ptr Rectangle ->
IO ()
rectangleUnion ::
(B.CallStack.HasCallStack, MonadIO m) =>
Rectangle
-> Rectangle
-> m (Rectangle)
rectangleUnion src1 src2 = liftIO $ do
src1' <- unsafeManagedPtrGetPtr src1
src2' <- unsafeManagedPtrGetPtr src2
dest <- callocBoxedBytes 16 :: IO (Ptr Rectangle)
gdk_rectangle_union src1' src2' dest
dest' <- (wrapBoxed Rectangle) dest
touchManagedPtr src1
touchManagedPtr src2
return dest'
#if defined(ENABLE_OVERLOADING)
data RectangleUnionMethodInfo
instance (signature ~ (Rectangle -> m (Rectangle)), MonadIO m) => O.MethodInfo RectangleUnionMethodInfo Rectangle signature where
overloadedMethod = rectangleUnion
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveRectangleMethod (t :: Symbol) (o :: *) :: * where
ResolveRectangleMethod "equal" o = RectangleEqualMethodInfo
ResolveRectangleMethod "intersect" o = RectangleIntersectMethodInfo
ResolveRectangleMethod "union" o = RectangleUnionMethodInfo
ResolveRectangleMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveRectangleMethod t Rectangle, O.MethodInfo info Rectangle p) => OL.IsLabel t (Rectangle -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif