packages feed

gi-pango-0.1.38.13: GI/Pango/Structs/AttrShape.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)

The #PangoAttrShape structure is used to represent attributes which
impose shape restrictions.
-}

module GI.Pango.Structs.AttrShape
    ( 

-- * Exported types
    AttrShape(..)                           ,
    newZeroAttrShape                        ,
    noAttrShape                             ,


 -- * Properties
-- ** Attr
    attrShapeReadAttr                       ,


-- ** Data
    attrShapeReadData                       ,


-- ** InkRect
    attrShapeReadInkRect                    ,


-- ** LogicalRect
    attrShapeReadLogicalRect                ,




    ) 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.Pango.Types
import GI.Pango.Callbacks

newtype AttrShape = AttrShape (ForeignPtr AttrShape)
-- | Construct a `AttrShape` struct initialized to zero.
newZeroAttrShape :: MonadIO m => m AttrShape
newZeroAttrShape = liftIO $ callocBytes 72 >>= wrapPtr AttrShape

noAttrShape :: Maybe AttrShape
noAttrShape = Nothing

attrShapeReadAttr :: AttrShape -> IO Attribute
attrShapeReadAttr s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr Attribute)
    val' <- (newPtr 16 Attribute) val
    return val'

attrShapeReadInkRect :: AttrShape -> IO Rectangle
attrShapeReadInkRect s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO (Ptr Rectangle)
    val' <- (newPtr 16 Rectangle) val
    return val'

attrShapeReadLogicalRect :: AttrShape -> IO Rectangle
attrShapeReadLogicalRect s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 32) :: IO (Ptr Rectangle)
    val' <- (newPtr 16 Rectangle) val
    return val'

attrShapeReadData :: AttrShape -> IO (Ptr ())
attrShapeReadData s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 48) :: IO (Ptr ())
    return val

-- XXX Skipped getter for "AttrShape:destroy_func" :: Not implemented: "Wrapping foreign callbacks is not supported yet"

type family ResolveAttrShapeMethod (t :: Symbol) (o :: *) :: * where
    ResolveAttrShapeMethod l o = MethodResolutionFailed l o

instance (info ~ ResolveAttrShapeMethod t AttrShape, MethodInfo info AttrShape p) => IsLabelProxy t (AttrShape -> p) where
    fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveAttrShapeMethod t AttrShape, MethodInfo info AttrShape p) => IsLabel t (AttrShape -> p) where
    fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif