packages feed

gi-pango-0.1.38.13: GI/Pango/Structs/Rectangle.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 #PangoRectangle structure represents a rectangle. It is frequently
used to represent the logical or ink extents of a single glyph or section
of text. (See, for instance, pango_font_get_glyph_extents())
-}

module GI.Pango.Structs.Rectangle
    ( 

-- * Exported types
    Rectangle(..)                           ,
    newZeroRectangle                        ,
    noRectangle                             ,


 -- * Properties
-- ** Height
    rectangleReadHeight                     ,


-- ** Width
    rectangleReadWidth                      ,


-- ** X
    rectangleReadX                          ,


-- ** Y
    rectangleReadY                          ,




    ) 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 Rectangle = Rectangle (ForeignPtr Rectangle)
-- | Construct a `Rectangle` struct initialized to zero.
newZeroRectangle :: MonadIO m => m Rectangle
newZeroRectangle = liftIO $ callocBytes 16 >>= wrapPtr Rectangle

noRectangle :: Maybe Rectangle
noRectangle = Nothing

rectangleReadX :: Rectangle -> IO Int32
rectangleReadX s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Int32
    return val

rectangleReadY :: Rectangle -> IO Int32
rectangleReadY s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 4) :: IO Int32
    return val

rectangleReadWidth :: Rectangle -> IO Int32
rectangleReadWidth s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO Int32
    return val

rectangleReadHeight :: Rectangle -> IO Int32
rectangleReadHeight s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 12) :: IO Int32
    return val

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

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

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