{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) /No description available in the introspection data./ -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.Cairo.Structs.Rectangle ( -- * Exported types Rectangle(..) , newZeroRectangle , noRectangle , -- * Properties -- ** height #attr:height# {- | /No description available in the introspection data./ -} getRectangleHeight , #if ENABLE_OVERLOADING rectangle_height , #endif setRectangleHeight , -- ** width #attr:width# {- | /No description available in the introspection data./ -} getRectangleWidth , #if ENABLE_OVERLOADING rectangle_width , #endif setRectangleWidth , -- ** x #attr:x# {- | /No description available in the introspection data./ -} getRectangleX , #if ENABLE_OVERLOADING rectangle_x , #endif setRectangleX , -- ** y #attr:y# {- | /No description available in the introspection data./ -} 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.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.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 -- | Memory-managed wrapper type. 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 _ = c_cairo_gobject_rectangle_get_type -- | Construct a `Rectangle` struct initialized to zero. newZeroRectangle :: MonadIO m => m Rectangle newZeroRectangle = liftIO $ callocBoxedBytes 32 >>= wrapBoxed Rectangle instance tag ~ 'AttrSet => Constructible Rectangle tag where new _ attrs = do o <- newZeroRectangle GI.Attributes.set o attrs return o -- | A convenience alias for `Nothing` :: `Maybe` `Rectangle`. noRectangle :: Maybe Rectangle noRectangle = Nothing {- | Get the value of the “@x@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.get' rectangle #x @ -} getRectangleX :: MonadIO m => Rectangle -> m Double getRectangleX s = liftIO $ withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 0) :: IO CDouble let val' = realToFrac val return val' {- | Set the value of the “@x@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.set' rectangle [ #x 'Data.GI.Base.Attributes.:=' value ] @ -} setRectangleX :: MonadIO m => Rectangle -> Double -> m () setRectangleX s val = liftIO $ withManagedPtr s $ \ptr -> do let val' = realToFrac val poke (ptr `plusPtr` 0) (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 {- | Get the value of the “@y@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.get' rectangle #y @ -} getRectangleY :: MonadIO m => Rectangle -> m Double getRectangleY s = liftIO $ withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 8) :: IO CDouble let val' = realToFrac val return val' {- | Set the value of the “@y@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.set' rectangle [ #y 'Data.GI.Base.Attributes.:=' value ] @ -} setRectangleY :: MonadIO m => Rectangle -> Double -> m () setRectangleY s val = liftIO $ withManagedPtr s $ \ptr -> do let val' = realToFrac val poke (ptr `plusPtr` 8) (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 {- | Get the value of the “@width@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.get' rectangle #width @ -} getRectangleWidth :: MonadIO m => Rectangle -> m Double getRectangleWidth s = liftIO $ withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 16) :: IO CDouble let val' = realToFrac val return val' {- | Set the value of the “@width@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.set' rectangle [ #width 'Data.GI.Base.Attributes.:=' value ] @ -} setRectangleWidth :: MonadIO m => Rectangle -> Double -> m () setRectangleWidth s val = liftIO $ withManagedPtr s $ \ptr -> do let val' = realToFrac val poke (ptr `plusPtr` 16) (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 {- | Get the value of the “@height@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.get' rectangle #height @ -} getRectangleHeight :: MonadIO m => Rectangle -> m Double getRectangleHeight s = liftIO $ withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 24) :: IO CDouble let val' = realToFrac val return val' {- | Set the value of the “@height@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.set' rectangle [ #height 'Data.GI.Base.Attributes.:=' value ] @ -} setRectangleHeight :: MonadIO m => Rectangle -> Double -> m () setRectangleHeight s val = liftIO $ withManagedPtr s $ \ptr -> do let val' = realToFrac val poke (ptr `plusPtr` 24) (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) => OL.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