packages feed

gi-gdk-0.3.18.13: GI/Gdk/Structs/Point.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)

Defines the x and y coordinates of a point.
-}

module GI.Gdk.Structs.Point
    ( 

-- * Exported types
    Point(..)                               ,
    newZeroPoint                            ,
    noPoint                                 ,


 -- * Properties
-- ** X
    pointReadX                              ,


-- ** Y
    pointReadY                              ,




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

newtype Point = Point (ForeignPtr Point)
-- | Construct a `Point` struct initialized to zero.
newZeroPoint :: MonadIO m => m Point
newZeroPoint = liftIO $ callocBytes 8 >>= wrapPtr Point

noPoint :: Maybe Point
noPoint = Nothing

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

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

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

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

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