#define ENABLE_OVERLOADING \
(!defined(__HADDOCK_VERSION__))
module GI.Cairo.Structs.Rectangle
(
Rectangle(..) ,
newZeroRectangle ,
noRectangle ,
getRectangleHeight ,
#if ENABLE_OVERLOADING
rectangle_height ,
#endif
setRectangleHeight ,
getRectangleWidth ,
#if ENABLE_OVERLOADING
rectangle_width ,
#endif
setRectangleWidth ,
getRectangleX ,
#if ENABLE_OVERLOADING
rectangle_x ,
#endif
setRectangleX ,
getRectangleY ,
#if 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.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 Rectangle = Rectangle (ManagedPtr Rectangle)
foreign import ccall "cairo_gobject_rectangle_get_type" c_cairo_gobject_rectangle_get_type ::
IO GType
instance BoxedObject Rectangle where
boxedType :: Rectangle -> IO GType
boxedType _ = IO GType
c_cairo_gobject_rectangle_get_type
newZeroRectangle :: MonadIO m => m Rectangle
newZeroRectangle :: m Rectangle
newZeroRectangle = IO Rectangle -> m Rectangle
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Rectangle -> m Rectangle) -> IO Rectangle -> m Rectangle
forall a b. (a -> b) -> a -> b
$ Int -> IO (Ptr Rectangle)
forall a. BoxedObject a => Int -> IO (Ptr a)
callocBoxedBytes 32 IO (Ptr Rectangle)
-> (Ptr Rectangle -> IO Rectangle) -> IO Rectangle
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr Rectangle -> Rectangle)
-> Ptr Rectangle -> IO Rectangle
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Rectangle -> Rectangle
Rectangle
instance tag ~ 'AttrSet => Constructible Rectangle tag where
new :: (ManagedPtr Rectangle -> Rectangle)
-> [AttrOp Rectangle tag] -> m Rectangle
new _ attrs :: [AttrOp Rectangle tag]
attrs = do
Rectangle
o <- m Rectangle
forall (m :: * -> *). MonadIO m => m Rectangle
newZeroRectangle
Rectangle -> [AttrOp Rectangle 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set Rectangle
o [AttrOp Rectangle tag]
[AttrOp Rectangle 'AttrSet]
attrs
Rectangle -> m Rectangle
forall (m :: * -> *) a. Monad m => a -> m a
return Rectangle
o
noRectangle :: Maybe Rectangle
noRectangle :: Maybe Rectangle
noRectangle = Maybe Rectangle
forall a. Maybe a
Nothing
getRectangleX :: MonadIO m => Rectangle -> m Double
getRectangleX :: Rectangle -> m Double
getRectangleX s :: Rectangle
s = IO Double -> m Double
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> m Double) -> IO Double -> m Double
forall a b. (a -> b) -> a -> b
$ Rectangle -> (Ptr Rectangle -> IO Double) -> IO Double
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Rectangle
s ((Ptr Rectangle -> IO Double) -> IO Double)
-> (Ptr Rectangle -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr Rectangle
ptr -> do
CDouble
val <- Ptr CDouble -> IO CDouble
forall a. Storable a => Ptr a -> IO a
peek (Ptr Rectangle
ptr Ptr Rectangle -> Int -> Ptr CDouble
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) :: IO CDouble
let val' :: Double
val' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
val
Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return Double
val'
setRectangleX :: MonadIO m => Rectangle -> Double -> m ()
setRectangleX :: Rectangle -> Double -> m ()
setRectangleX s :: Rectangle
s val :: Double
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Rectangle -> (Ptr Rectangle -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Rectangle
s ((Ptr Rectangle -> IO ()) -> IO ())
-> (Ptr Rectangle -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr Rectangle
ptr -> do
let val' :: CDouble
val' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
val
Ptr CDouble -> CDouble -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Rectangle
ptr Ptr Rectangle -> Int -> Ptr CDouble
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) (CDouble
val' :: CDouble)
#if ENABLE_OVERLOADING
data RectangleXFieldInfo
instance AttrInfo RectangleXFieldInfo where
type AttrAllowedOps RectangleXFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint RectangleXFieldInfo = (~) Double
type AttrBaseTypeConstraint RectangleXFieldInfo = (~) Rectangle
type AttrGetType RectangleXFieldInfo = Double
type AttrLabel RectangleXFieldInfo = "x"
type AttrOrigin RectangleXFieldInfo = Rectangle
attrGet _ = getRectangleX
attrSet _ = setRectangleX
attrConstruct = undefined
attrClear _ = undefined
rectangle_x :: AttrLabelProxy "x"
rectangle_x = AttrLabelProxy
#endif
getRectangleY :: MonadIO m => Rectangle -> m Double
getRectangleY :: Rectangle -> m Double
getRectangleY s :: Rectangle
s = IO Double -> m Double
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> m Double) -> IO Double -> m Double
forall a b. (a -> b) -> a -> b
$ Rectangle -> (Ptr Rectangle -> IO Double) -> IO Double
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Rectangle
s ((Ptr Rectangle -> IO Double) -> IO Double)
-> (Ptr Rectangle -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr Rectangle
ptr -> do
CDouble
val <- Ptr CDouble -> IO CDouble
forall a. Storable a => Ptr a -> IO a
peek (Ptr Rectangle
ptr Ptr Rectangle -> Int -> Ptr CDouble
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8) :: IO CDouble
let val' :: Double
val' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
val
Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return Double
val'
setRectangleY :: MonadIO m => Rectangle -> Double -> m ()
setRectangleY :: Rectangle -> Double -> m ()
setRectangleY s :: Rectangle
s val :: Double
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Rectangle -> (Ptr Rectangle -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Rectangle
s ((Ptr Rectangle -> IO ()) -> IO ())
-> (Ptr Rectangle -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr Rectangle
ptr -> do
let val' :: CDouble
val' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
val
Ptr CDouble -> CDouble -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Rectangle
ptr Ptr Rectangle -> Int -> Ptr CDouble
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8) (CDouble
val' :: CDouble)
#if ENABLE_OVERLOADING
data RectangleYFieldInfo
instance AttrInfo RectangleYFieldInfo where
type AttrAllowedOps RectangleYFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint RectangleYFieldInfo = (~) Double
type AttrBaseTypeConstraint RectangleYFieldInfo = (~) Rectangle
type AttrGetType RectangleYFieldInfo = Double
type AttrLabel RectangleYFieldInfo = "y"
type AttrOrigin RectangleYFieldInfo = Rectangle
attrGet _ = getRectangleY
attrSet _ = setRectangleY
attrConstruct = undefined
attrClear _ = undefined
rectangle_y :: AttrLabelProxy "y"
rectangle_y = AttrLabelProxy
#endif
getRectangleWidth :: MonadIO m => Rectangle -> m Double
getRectangleWidth :: Rectangle -> m Double
getRectangleWidth s :: Rectangle
s = IO Double -> m Double
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> m Double) -> IO Double -> m Double
forall a b. (a -> b) -> a -> b
$ Rectangle -> (Ptr Rectangle -> IO Double) -> IO Double
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Rectangle
s ((Ptr Rectangle -> IO Double) -> IO Double)
-> (Ptr Rectangle -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr Rectangle
ptr -> do
CDouble
val <- Ptr CDouble -> IO CDouble
forall a. Storable a => Ptr a -> IO a
peek (Ptr Rectangle
ptr Ptr Rectangle -> Int -> Ptr CDouble
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) :: IO CDouble
let val' :: Double
val' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
val
Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return Double
val'
setRectangleWidth :: MonadIO m => Rectangle -> Double -> m ()
setRectangleWidth :: Rectangle -> Double -> m ()
setRectangleWidth s :: Rectangle
s val :: Double
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Rectangle -> (Ptr Rectangle -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Rectangle
s ((Ptr Rectangle -> IO ()) -> IO ())
-> (Ptr Rectangle -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr Rectangle
ptr -> do
let val' :: CDouble
val' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
val
Ptr CDouble -> CDouble -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Rectangle
ptr Ptr Rectangle -> Int -> Ptr CDouble
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) (CDouble
val' :: CDouble)
#if ENABLE_OVERLOADING
data RectangleWidthFieldInfo
instance AttrInfo RectangleWidthFieldInfo where
type AttrAllowedOps RectangleWidthFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint RectangleWidthFieldInfo = (~) Double
type AttrBaseTypeConstraint RectangleWidthFieldInfo = (~) Rectangle
type AttrGetType RectangleWidthFieldInfo = Double
type AttrLabel RectangleWidthFieldInfo = "width"
type AttrOrigin RectangleWidthFieldInfo = Rectangle
attrGet _ = getRectangleWidth
attrSet _ = setRectangleWidth
attrConstruct = undefined
attrClear _ = undefined
rectangle_width :: AttrLabelProxy "width"
rectangle_width = AttrLabelProxy
#endif
getRectangleHeight :: MonadIO m => Rectangle -> m Double
getRectangleHeight :: Rectangle -> m Double
getRectangleHeight s :: Rectangle
s = IO Double -> m Double
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> m Double) -> IO Double -> m Double
forall a b. (a -> b) -> a -> b
$ Rectangle -> (Ptr Rectangle -> IO Double) -> IO Double
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Rectangle
s ((Ptr Rectangle -> IO Double) -> IO Double)
-> (Ptr Rectangle -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr Rectangle
ptr -> do
CDouble
val <- Ptr CDouble -> IO CDouble
forall a. Storable a => Ptr a -> IO a
peek (Ptr Rectangle
ptr Ptr Rectangle -> Int -> Ptr CDouble
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24) :: IO CDouble
let val' :: Double
val' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
val
Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return Double
val'
setRectangleHeight :: MonadIO m => Rectangle -> Double -> m ()
setRectangleHeight :: Rectangle -> Double -> m ()
setRectangleHeight s :: Rectangle
s val :: Double
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Rectangle -> (Ptr Rectangle -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Rectangle
s ((Ptr Rectangle -> IO ()) -> IO ())
-> (Ptr Rectangle -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr Rectangle
ptr -> do
let val' :: CDouble
val' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
val
Ptr CDouble -> CDouble -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Rectangle
ptr Ptr Rectangle -> Int -> Ptr CDouble
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24) (CDouble
val' :: CDouble)
#if ENABLE_OVERLOADING
data RectangleHeightFieldInfo
instance AttrInfo RectangleHeightFieldInfo where
type AttrAllowedOps RectangleHeightFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint RectangleHeightFieldInfo = (~) Double
type AttrBaseTypeConstraint RectangleHeightFieldInfo = (~) Rectangle
type AttrGetType RectangleHeightFieldInfo = Double
type AttrLabel RectangleHeightFieldInfo = "height"
type AttrOrigin RectangleHeightFieldInfo = Rectangle
attrGet _ = getRectangleHeight
attrSet _ = setRectangleHeight
attrConstruct = undefined
attrClear _ = undefined
rectangle_height :: AttrLabelProxy "height"
rectangle_height = AttrLabelProxy
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList Rectangle
type instance O.AttributeList Rectangle = RectangleAttributeList
type RectangleAttributeList = ('[ '("x", RectangleXFieldInfo), '("y", RectangleYFieldInfo), '("width", RectangleWidthFieldInfo), '("height", RectangleHeightFieldInfo)] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
type family ResolveRectangleMethod (t :: Symbol) (o :: *) :: * where
ResolveRectangleMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveRectangleMethod t Rectangle, O.MethodInfo info Rectangle p) => O.IsLabelProxy t (Rectangle -> p) where
fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveRectangleMethod t Rectangle, O.MethodInfo info Rectangle p) => O.IsLabel t (Rectangle -> 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