{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) -} module GI.Gdk.Objects.Cursor ( -- * Exported types Cursor(..) , CursorK , toCursor , noCursor , -- * Methods -- ** cursorGetCursorType cursorGetCursorType , -- ** cursorGetDisplay cursorGetDisplay , -- ** cursorGetImage cursorGetImage , -- ** cursorGetSurface cursorGetSurface , -- ** cursorNew cursorNew , -- ** cursorNewForDisplay cursorNewForDisplay , -- ** cursorNewFromName cursorNewFromName , -- ** cursorNewFromPixbuf cursorNewFromPixbuf , -- ** cursorNewFromSurface cursorNewFromSurface , -- ** cursorRef cursorRef , -- ** cursorUnref cursorUnref , -- * Properties -- ** CursorType CursorCursorTypePropertyInfo , constructCursorCursorType , getCursorCursorType , -- ** Display CursorDisplayPropertyInfo , constructCursorDisplay , getCursorDisplay , ) 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 import qualified GI.GObject as GObject import qualified GI.GdkPixbuf as GdkPixbuf import qualified GI.Cairo as Cairo newtype Cursor = Cursor (ForeignPtr Cursor) foreign import ccall "gdk_cursor_get_type" c_gdk_cursor_get_type :: IO GType type instance ParentTypes Cursor = CursorParentTypes type CursorParentTypes = '[GObject.Object] instance GObject Cursor where gobjectIsInitiallyUnowned _ = False gobjectType _ = c_gdk_cursor_get_type class GObject o => CursorK o instance (GObject o, IsDescendantOf Cursor o) => CursorK o toCursor :: CursorK o => o -> IO Cursor toCursor = unsafeCastTo Cursor noCursor :: Maybe Cursor noCursor = Nothing -- VVV Prop "cursor-type" -- Type: TInterface "Gdk" "CursorType" -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly] getCursorCursorType :: (MonadIO m, CursorK o) => o -> m CursorType getCursorCursorType obj = liftIO $ getObjectPropertyEnum obj "cursor-type" constructCursorCursorType :: CursorType -> IO ([Char], GValue) constructCursorCursorType val = constructObjectPropertyEnum "cursor-type" val data CursorCursorTypePropertyInfo instance AttrInfo CursorCursorTypePropertyInfo where type AttrAllowedOps CursorCursorTypePropertyInfo = '[ 'AttrConstruct, 'AttrGet] type AttrSetTypeConstraint CursorCursorTypePropertyInfo = (~) CursorType type AttrBaseTypeConstraint CursorCursorTypePropertyInfo = CursorK type AttrGetType CursorCursorTypePropertyInfo = CursorType type AttrLabel CursorCursorTypePropertyInfo = "Cursor::cursor-type" attrGet _ = getCursorCursorType attrSet _ = undefined attrConstruct _ = constructCursorCursorType -- VVV Prop "display" -- Type: TInterface "Gdk" "Display" -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly] getCursorDisplay :: (MonadIO m, CursorK o) => o -> m Display getCursorDisplay obj = liftIO $ getObjectPropertyObject obj "display" Display constructCursorDisplay :: (DisplayK a) => a -> IO ([Char], GValue) constructCursorDisplay val = constructObjectPropertyObject "display" val data CursorDisplayPropertyInfo instance AttrInfo CursorDisplayPropertyInfo where type AttrAllowedOps CursorDisplayPropertyInfo = '[ 'AttrConstruct, 'AttrGet] type AttrSetTypeConstraint CursorDisplayPropertyInfo = DisplayK type AttrBaseTypeConstraint CursorDisplayPropertyInfo = CursorK type AttrGetType CursorDisplayPropertyInfo = Display type AttrLabel CursorDisplayPropertyInfo = "Cursor::display" attrGet _ = getCursorDisplay attrSet _ = undefined attrConstruct _ = constructCursorDisplay type instance AttributeList Cursor = CursorAttributeList type CursorAttributeList = ('[ '("cursor-type", CursorCursorTypePropertyInfo), '("display", CursorDisplayPropertyInfo)] :: [(Symbol, *)]) type instance SignalList Cursor = CursorSignalList type CursorSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)]) -- method Cursor::new -- method type : Constructor -- Args : [Arg {argName = "cursor_type", argType = TInterface "Gdk" "CursorType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "cursor_type", argType = TInterface "Gdk" "CursorType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gdk" "Cursor" -- throws : False -- Skip return : False foreign import ccall "gdk_cursor_new" gdk_cursor_new :: CUInt -> -- cursor_type : TInterface "Gdk" "CursorType" IO (Ptr Cursor) {-# DEPRECATED cursorNew ["(Since version 3.16)","Use gdk_cursor_new_for_display() instead."]#-} cursorNew :: (MonadIO m) => CursorType -> -- cursor_type m Cursor cursorNew cursor_type = liftIO $ do let cursor_type' = (fromIntegral . fromEnum) cursor_type result <- gdk_cursor_new cursor_type' checkUnexpectedReturnNULL "gdk_cursor_new" result result' <- (wrapObject Cursor) result return result' -- method Cursor::new_for_display -- method type : Constructor -- Args : [Arg {argName = "display", argType = TInterface "Gdk" "Display", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cursor_type", argType = TInterface "Gdk" "CursorType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "display", argType = TInterface "Gdk" "Display", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cursor_type", argType = TInterface "Gdk" "CursorType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gdk" "Cursor" -- throws : False -- Skip return : False foreign import ccall "gdk_cursor_new_for_display" gdk_cursor_new_for_display :: Ptr Display -> -- display : TInterface "Gdk" "Display" CUInt -> -- cursor_type : TInterface "Gdk" "CursorType" IO (Ptr Cursor) cursorNewForDisplay :: (MonadIO m, DisplayK a) => a -> -- display CursorType -> -- cursor_type m Cursor cursorNewForDisplay display cursor_type = liftIO $ do let display' = unsafeManagedPtrCastPtr display let cursor_type' = (fromIntegral . fromEnum) cursor_type result <- gdk_cursor_new_for_display display' cursor_type' checkUnexpectedReturnNULL "gdk_cursor_new_for_display" result result' <- (wrapObject Cursor) result touchManagedPtr display return result' -- method Cursor::new_from_name -- method type : Constructor -- Args : [Arg {argName = "display", argType = TInterface "Gdk" "Display", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "display", argType = TInterface "Gdk" "Display", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gdk" "Cursor" -- throws : False -- Skip return : False foreign import ccall "gdk_cursor_new_from_name" gdk_cursor_new_from_name :: Ptr Display -> -- display : TInterface "Gdk" "Display" CString -> -- name : TBasicType TUTF8 IO (Ptr Cursor) cursorNewFromName :: (MonadIO m, DisplayK a) => a -> -- display T.Text -> -- name m Cursor cursorNewFromName display name = liftIO $ do let display' = unsafeManagedPtrCastPtr display name' <- textToCString name result <- gdk_cursor_new_from_name display' name' checkUnexpectedReturnNULL "gdk_cursor_new_from_name" result result' <- (wrapObject Cursor) result touchManagedPtr display freeMem name' return result' -- method Cursor::new_from_pixbuf -- method type : Constructor -- Args : [Arg {argName = "display", argType = TInterface "Gdk" "Display", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "pixbuf", argType = TInterface "GdkPixbuf" "Pixbuf", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "x", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "y", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "display", argType = TInterface "Gdk" "Display", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "pixbuf", argType = TInterface "GdkPixbuf" "Pixbuf", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "x", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "y", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gdk" "Cursor" -- throws : False -- Skip return : False foreign import ccall "gdk_cursor_new_from_pixbuf" gdk_cursor_new_from_pixbuf :: Ptr Display -> -- display : TInterface "Gdk" "Display" Ptr GdkPixbuf.Pixbuf -> -- pixbuf : TInterface "GdkPixbuf" "Pixbuf" Int32 -> -- x : TBasicType TInt32 Int32 -> -- y : TBasicType TInt32 IO (Ptr Cursor) cursorNewFromPixbuf :: (MonadIO m, DisplayK a, GdkPixbuf.PixbufK b) => a -> -- display b -> -- pixbuf Int32 -> -- x Int32 -> -- y m Cursor cursorNewFromPixbuf display pixbuf x y = liftIO $ do let display' = unsafeManagedPtrCastPtr display let pixbuf' = unsafeManagedPtrCastPtr pixbuf result <- gdk_cursor_new_from_pixbuf display' pixbuf' x y checkUnexpectedReturnNULL "gdk_cursor_new_from_pixbuf" result result' <- (wrapObject Cursor) result touchManagedPtr display touchManagedPtr pixbuf return result' -- method Cursor::new_from_surface -- method type : Constructor -- Args : [Arg {argName = "display", argType = TInterface "Gdk" "Display", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "surface", argType = TInterface "cairo" "Surface", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "x", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "y", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "display", argType = TInterface "Gdk" "Display", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "surface", argType = TInterface "cairo" "Surface", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "x", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "y", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gdk" "Cursor" -- throws : False -- Skip return : False foreign import ccall "gdk_cursor_new_from_surface" gdk_cursor_new_from_surface :: Ptr Display -> -- display : TInterface "Gdk" "Display" Ptr Cairo.Surface -> -- surface : TInterface "cairo" "Surface" CDouble -> -- x : TBasicType TDouble CDouble -> -- y : TBasicType TDouble IO (Ptr Cursor) cursorNewFromSurface :: (MonadIO m, DisplayK a) => a -> -- display Cairo.Surface -> -- surface Double -> -- x Double -> -- y m Cursor cursorNewFromSurface display surface x y = liftIO $ do let display' = unsafeManagedPtrCastPtr display let surface' = unsafeManagedPtrGetPtr surface let x' = realToFrac x let y' = realToFrac y result <- gdk_cursor_new_from_surface display' surface' x' y' checkUnexpectedReturnNULL "gdk_cursor_new_from_surface" result result' <- (wrapObject Cursor) result touchManagedPtr display touchManagedPtr surface return result' -- method Cursor::get_cursor_type -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Cursor", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Cursor", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gdk" "CursorType" -- throws : False -- Skip return : False foreign import ccall "gdk_cursor_get_cursor_type" gdk_cursor_get_cursor_type :: Ptr Cursor -> -- _obj : TInterface "Gdk" "Cursor" IO CUInt cursorGetCursorType :: (MonadIO m, CursorK a) => a -> -- _obj m CursorType cursorGetCursorType _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- gdk_cursor_get_cursor_type _obj' let result' = (toEnum . fromIntegral) result touchManagedPtr _obj return result' -- method Cursor::get_display -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Cursor", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Cursor", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gdk" "Display" -- throws : False -- Skip return : False foreign import ccall "gdk_cursor_get_display" gdk_cursor_get_display :: Ptr Cursor -> -- _obj : TInterface "Gdk" "Cursor" IO (Ptr Display) cursorGetDisplay :: (MonadIO m, CursorK a) => a -> -- _obj m Display cursorGetDisplay _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- gdk_cursor_get_display _obj' checkUnexpectedReturnNULL "gdk_cursor_get_display" result result' <- (newObject Display) result touchManagedPtr _obj return result' -- method Cursor::get_image -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Cursor", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Cursor", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "GdkPixbuf" "Pixbuf" -- throws : False -- Skip return : False foreign import ccall "gdk_cursor_get_image" gdk_cursor_get_image :: Ptr Cursor -> -- _obj : TInterface "Gdk" "Cursor" IO (Ptr GdkPixbuf.Pixbuf) cursorGetImage :: (MonadIO m, CursorK a) => a -> -- _obj m GdkPixbuf.Pixbuf cursorGetImage _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- gdk_cursor_get_image _obj' checkUnexpectedReturnNULL "gdk_cursor_get_image" result result' <- (wrapObject GdkPixbuf.Pixbuf) result touchManagedPtr _obj return result' -- method Cursor::get_surface -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Cursor", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "x_hot", argType = TBasicType TDouble, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "y_hot", argType = TBasicType TDouble, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Cursor", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "cairo" "Surface" -- throws : False -- Skip return : False foreign import ccall "gdk_cursor_get_surface" gdk_cursor_get_surface :: Ptr Cursor -> -- _obj : TInterface "Gdk" "Cursor" Ptr CDouble -> -- x_hot : TBasicType TDouble Ptr CDouble -> -- y_hot : TBasicType TDouble IO (Ptr Cairo.Surface) cursorGetSurface :: (MonadIO m, CursorK a) => a -> -- _obj m (Cairo.Surface,Double,Double) cursorGetSurface _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj x_hot <- allocMem :: IO (Ptr CDouble) y_hot <- allocMem :: IO (Ptr CDouble) result <- gdk_cursor_get_surface _obj' x_hot y_hot checkUnexpectedReturnNULL "gdk_cursor_get_surface" result result' <- (wrapBoxed Cairo.Surface) result x_hot' <- peek x_hot let x_hot'' = realToFrac x_hot' y_hot' <- peek y_hot let y_hot'' = realToFrac y_hot' touchManagedPtr _obj freeMem x_hot freeMem y_hot return (result', x_hot'', y_hot'') -- method Cursor::ref -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Cursor", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Cursor", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gdk" "Cursor" -- throws : False -- Skip return : False foreign import ccall "gdk_cursor_ref" gdk_cursor_ref :: Ptr Cursor -> -- _obj : TInterface "Gdk" "Cursor" IO (Ptr Cursor) {-# DEPRECATED cursorRef ["(Since version 3.0)","Use g_object_ref() instead"]#-} cursorRef :: (MonadIO m, CursorK a) => a -> -- _obj m Cursor cursorRef _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- gdk_cursor_ref _obj' checkUnexpectedReturnNULL "gdk_cursor_ref" result result' <- (wrapObject Cursor) result touchManagedPtr _obj return result' -- method Cursor::unref -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Cursor", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Cursor", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "gdk_cursor_unref" gdk_cursor_unref :: Ptr Cursor -> -- _obj : TInterface "Gdk" "Cursor" IO () {-# DEPRECATED cursorUnref ["(Since version 3.0)","Use g_object_unref() instead"]#-} cursorUnref :: (MonadIO m, CursorK a) => a -> -- _obj m () cursorUnref _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj gdk_cursor_unref _obj' touchManagedPtr _obj return ()