{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gdk.Objects.CairoContext
(
CairoContext(..) ,
IsCairoContext ,
toCairoContext ,
#if defined(ENABLE_OVERLOADING)
ResolveCairoContextMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
CairoContextCairoCreateMethodInfo ,
#endif
cairoContextCairoCreate ,
) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
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
import qualified GHC.Records as R
import qualified GI.Cairo.Structs.Context as Cairo.Context
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gdk.Objects.DrawContext as Gdk.DrawContext
newtype CairoContext = CairoContext (SP.ManagedPtr CairoContext)
deriving (CairoContext -> CairoContext -> Bool
(CairoContext -> CairoContext -> Bool)
-> (CairoContext -> CairoContext -> Bool) -> Eq CairoContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CairoContext -> CairoContext -> Bool
== :: CairoContext -> CairoContext -> Bool
$c/= :: CairoContext -> CairoContext -> Bool
/= :: CairoContext -> CairoContext -> Bool
Eq)
instance SP.ManagedPtrNewtype CairoContext where
toManagedPtr :: CairoContext -> ManagedPtr CairoContext
toManagedPtr (CairoContext ManagedPtr CairoContext
p) = ManagedPtr CairoContext
p
foreign import ccall "gdk_cairo_context_get_type"
c_gdk_cairo_context_get_type :: IO B.Types.GType
instance B.Types.TypedObject CairoContext where
glibType :: IO GType
glibType = IO GType
c_gdk_cairo_context_get_type
instance B.Types.GObject CairoContext
class (SP.GObject o, O.IsDescendantOf CairoContext o) => IsCairoContext o
instance (SP.GObject o, O.IsDescendantOf CairoContext o) => IsCairoContext o
instance O.HasParentTypes CairoContext
type instance O.ParentTypes CairoContext = '[Gdk.DrawContext.DrawContext, GObject.Object.Object]
toCairoContext :: (MIO.MonadIO m, IsCairoContext o) => o -> m CairoContext
toCairoContext :: forall (m :: * -> *) o.
(MonadIO m, IsCairoContext o) =>
o -> m CairoContext
toCairoContext = IO CairoContext -> m CairoContext
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO CairoContext -> m CairoContext)
-> (o -> IO CairoContext) -> o -> m CairoContext
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr CairoContext -> CairoContext) -> o -> IO CairoContext
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr CairoContext -> CairoContext
CairoContext
instance B.GValue.IsGValue (Maybe CairoContext) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_gdk_cairo_context_get_type
gvalueSet_ :: Ptr GValue -> Maybe CairoContext -> IO ()
gvalueSet_ Ptr GValue
gv Maybe CairoContext
P.Nothing = Ptr GValue -> Ptr CairoContext -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr CairoContext
forall a. Ptr a
FP.nullPtr :: FP.Ptr CairoContext)
gvalueSet_ Ptr GValue
gv (P.Just CairoContext
obj) = CairoContext -> (Ptr CairoContext -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr CairoContext
obj (Ptr GValue -> Ptr CairoContext -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe CairoContext)
gvalueGet_ Ptr GValue
gv = do
Ptr CairoContext
ptr <- Ptr GValue -> IO (Ptr CairoContext)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr CairoContext)
if Ptr CairoContext
ptr Ptr CairoContext -> Ptr CairoContext -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr CairoContext
forall a. Ptr a
FP.nullPtr
then CairoContext -> Maybe CairoContext
forall a. a -> Maybe a
P.Just (CairoContext -> Maybe CairoContext)
-> IO CairoContext -> IO (Maybe CairoContext)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr CairoContext -> CairoContext)
-> Ptr CairoContext -> IO CairoContext
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr CairoContext -> CairoContext
CairoContext Ptr CairoContext
ptr
else Maybe CairoContext -> IO (Maybe CairoContext)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe CairoContext
forall a. Maybe a
P.Nothing
#if defined(ENABLE_OVERLOADING)
type family ResolveCairoContextMethod (t :: Symbol) (o :: *) :: * where
ResolveCairoContextMethod "beginFrame" o = Gdk.DrawContext.DrawContextBeginFrameMethodInfo
ResolveCairoContextMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveCairoContextMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveCairoContextMethod "cairoCreate" o = CairoContextCairoCreateMethodInfo
ResolveCairoContextMethod "endFrame" o = Gdk.DrawContext.DrawContextEndFrameMethodInfo
ResolveCairoContextMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveCairoContextMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveCairoContextMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveCairoContextMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveCairoContextMethod "isInFrame" o = Gdk.DrawContext.DrawContextIsInFrameMethodInfo
ResolveCairoContextMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveCairoContextMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveCairoContextMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveCairoContextMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveCairoContextMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveCairoContextMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveCairoContextMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveCairoContextMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveCairoContextMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveCairoContextMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveCairoContextMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveCairoContextMethod "getDisplay" o = Gdk.DrawContext.DrawContextGetDisplayMethodInfo
ResolveCairoContextMethod "getFrameRegion" o = Gdk.DrawContext.DrawContextGetFrameRegionMethodInfo
ResolveCairoContextMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveCairoContextMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveCairoContextMethod "getSurface" o = Gdk.DrawContext.DrawContextGetSurfaceMethodInfo
ResolveCairoContextMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveCairoContextMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveCairoContextMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveCairoContextMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveCairoContextMethod t CairoContext, O.OverloadedMethod info CairoContext p) => OL.IsLabel t (CairoContext -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveCairoContextMethod t CairoContext, O.OverloadedMethod info CairoContext p, R.HasField t CairoContext p) => R.HasField t CairoContext p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveCairoContextMethod t CairoContext, O.OverloadedMethodInfo info CairoContext) => OL.IsLabel t (O.MethodProxy info CairoContext) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList CairoContext
type instance O.AttributeList CairoContext = CairoContextAttributeList
type CairoContextAttributeList = ('[ '("display", Gdk.DrawContext.DrawContextDisplayPropertyInfo), '("surface", Gdk.DrawContext.DrawContextSurfacePropertyInfo)] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList CairoContext = CairoContextSignalList
type CairoContextSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "gdk_cairo_context_cairo_create" gdk_cairo_context_cairo_create ::
Ptr CairoContext ->
IO (Ptr Cairo.Context.Context)
cairoContextCairoCreate ::
(B.CallStack.HasCallStack, MonadIO m, IsCairoContext a) =>
a
-> m (Maybe Cairo.Context.Context)
cairoContextCairoCreate :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCairoContext a) =>
a -> m (Maybe Context)
cairoContextCairoCreate a
self = IO (Maybe Context) -> m (Maybe Context)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Context) -> m (Maybe Context))
-> IO (Maybe Context) -> m (Maybe Context)
forall a b. (a -> b) -> a -> b
$ do
Ptr CairoContext
self' <- a -> IO (Ptr CairoContext)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
self
Ptr Context
result <- Ptr CairoContext -> IO (Ptr Context)
gdk_cairo_context_cairo_create Ptr CairoContext
self'
Maybe Context
maybeResult <- Ptr Context -> (Ptr Context -> IO Context) -> IO (Maybe Context)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Context
result ((Ptr Context -> IO Context) -> IO (Maybe Context))
-> (Ptr Context -> IO Context) -> IO (Maybe Context)
forall a b. (a -> b) -> a -> b
$ \Ptr Context
result' -> do
Context
result'' <- ((ManagedPtr Context -> Context) -> Ptr Context -> IO Context
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Context -> Context
Cairo.Context.Context) Ptr Context
result'
Context -> IO Context
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Context
result''
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
self
Maybe Context -> IO (Maybe Context)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Context
maybeResult
#if defined(ENABLE_OVERLOADING)
data CairoContextCairoCreateMethodInfo
instance (signature ~ (m (Maybe Cairo.Context.Context)), MonadIO m, IsCairoContext a) => O.OverloadedMethod CairoContextCairoCreateMethodInfo a signature where
overloadedMethod = cairoContextCairoCreate
instance O.OverloadedMethodInfo CairoContextCairoCreateMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gdk.Objects.CairoContext.cairoContextCairoCreate",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gdk-4.0.5/docs/GI-Gdk-Objects-CairoContext.html#v:cairoContextCairoCreate"
})
#endif