{- |
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.DeviceTool
    ( 

-- * Exported types
    DeviceTool(..)                          ,
    IsDeviceTool                            ,
    toDeviceTool                            ,
    noDeviceTool                            ,


 -- * Methods
-- ** getHardwareId #method:getHardwareId#
    DeviceToolGetHardwareIdMethodInfo       ,
    deviceToolGetHardwareId                 ,


-- ** getSerial #method:getSerial#
    DeviceToolGetSerialMethodInfo           ,
    deviceToolGetSerial                     ,


-- ** getToolType #method:getToolType#
    DeviceToolGetToolTypeMethodInfo         ,
    deviceToolGetToolType                   ,




 -- * Properties
-- ** axes #attr:axes#
    DeviceToolAxesPropertyInfo              ,
    constructDeviceToolAxes                 ,
    deviceToolAxes                          ,
    getDeviceToolAxes                       ,


-- ** hardwareId #attr:hardwareId#
    DeviceToolHardwareIdPropertyInfo        ,
    constructDeviceToolHardwareId           ,
    deviceToolHardwareId                    ,
    getDeviceToolHardwareId                 ,


-- ** serial #attr:serial#
    DeviceToolSerialPropertyInfo            ,
    constructDeviceToolSerial               ,
    deviceToolSerial                        ,
    getDeviceToolSerial                     ,


-- ** toolType #attr:toolType#
    DeviceToolToolTypePropertyInfo          ,
    constructDeviceToolToolType             ,
    deviceToolToolType                      ,
    getDeviceToolToolType                   ,




    ) 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.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
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 GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gdk.Enums as Gdk.Enums
import {-# SOURCE #-} qualified GI.Gdk.Flags as Gdk.Flags

newtype DeviceTool = DeviceTool (ManagedPtr DeviceTool)
foreign import ccall "gdk_device_tool_get_type"
    c_gdk_device_tool_get_type :: IO GType

instance GObject DeviceTool where
    gobjectType _ = c_gdk_device_tool_get_type
    

class GObject o => IsDeviceTool o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError DeviceTool a) =>
    IsDeviceTool a
#endif
instance IsDeviceTool DeviceTool
instance GObject.Object.IsObject DeviceTool

toDeviceTool :: IsDeviceTool o => o -> IO DeviceTool
toDeviceTool = unsafeCastTo DeviceTool

noDeviceTool :: Maybe DeviceTool
noDeviceTool = Nothing

type family ResolveDeviceToolMethod (t :: Symbol) (o :: *) :: * where
    ResolveDeviceToolMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveDeviceToolMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveDeviceToolMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveDeviceToolMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveDeviceToolMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveDeviceToolMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveDeviceToolMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveDeviceToolMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveDeviceToolMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveDeviceToolMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveDeviceToolMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveDeviceToolMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveDeviceToolMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveDeviceToolMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveDeviceToolMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveDeviceToolMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveDeviceToolMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveDeviceToolMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveDeviceToolMethod "getHardwareId" o = DeviceToolGetHardwareIdMethodInfo
    ResolveDeviceToolMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveDeviceToolMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveDeviceToolMethod "getSerial" o = DeviceToolGetSerialMethodInfo
    ResolveDeviceToolMethod "getToolType" o = DeviceToolGetToolTypeMethodInfo
    ResolveDeviceToolMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveDeviceToolMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveDeviceToolMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveDeviceToolMethod t DeviceTool, O.MethodInfo info DeviceTool p) => O.IsLabelProxy t (DeviceTool -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

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

-- VVV Prop "axes"
   -- Type: TInterface (Name {namespace = "Gdk", name = "AxisFlags"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

getDeviceToolAxes :: (MonadIO m, IsDeviceTool o) => o -> m [Gdk.Flags.AxisFlags]
getDeviceToolAxes obj = liftIO $ getObjectPropertyFlags obj "axes"

constructDeviceToolAxes :: (IsDeviceTool o) => [Gdk.Flags.AxisFlags] -> IO (GValueConstruct o)
constructDeviceToolAxes val = constructObjectPropertyFlags "axes" val

data DeviceToolAxesPropertyInfo
instance AttrInfo DeviceToolAxesPropertyInfo where
    type AttrAllowedOps DeviceToolAxesPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DeviceToolAxesPropertyInfo = (~) [Gdk.Flags.AxisFlags]
    type AttrBaseTypeConstraint DeviceToolAxesPropertyInfo = IsDeviceTool
    type AttrGetType DeviceToolAxesPropertyInfo = [Gdk.Flags.AxisFlags]
    type AttrLabel DeviceToolAxesPropertyInfo = "axes"
    type AttrOrigin DeviceToolAxesPropertyInfo = DeviceTool
    attrGet _ = getDeviceToolAxes
    attrSet _ = undefined
    attrConstruct _ = constructDeviceToolAxes
    attrClear _ = undefined

-- VVV Prop "hardware-id"
   -- Type: TBasicType TUInt64
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getDeviceToolHardwareId :: (MonadIO m, IsDeviceTool o) => o -> m Word64
getDeviceToolHardwareId obj = liftIO $ getObjectPropertyUInt64 obj "hardware-id"

constructDeviceToolHardwareId :: (IsDeviceTool o) => Word64 -> IO (GValueConstruct o)
constructDeviceToolHardwareId val = constructObjectPropertyUInt64 "hardware-id" val

data DeviceToolHardwareIdPropertyInfo
instance AttrInfo DeviceToolHardwareIdPropertyInfo where
    type AttrAllowedOps DeviceToolHardwareIdPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DeviceToolHardwareIdPropertyInfo = (~) Word64
    type AttrBaseTypeConstraint DeviceToolHardwareIdPropertyInfo = IsDeviceTool
    type AttrGetType DeviceToolHardwareIdPropertyInfo = Word64
    type AttrLabel DeviceToolHardwareIdPropertyInfo = "hardware-id"
    type AttrOrigin DeviceToolHardwareIdPropertyInfo = DeviceTool
    attrGet _ = getDeviceToolHardwareId
    attrSet _ = undefined
    attrConstruct _ = constructDeviceToolHardwareId
    attrClear _ = undefined

-- VVV Prop "serial"
   -- Type: TBasicType TUInt64
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getDeviceToolSerial :: (MonadIO m, IsDeviceTool o) => o -> m Word64
getDeviceToolSerial obj = liftIO $ getObjectPropertyUInt64 obj "serial"

constructDeviceToolSerial :: (IsDeviceTool o) => Word64 -> IO (GValueConstruct o)
constructDeviceToolSerial val = constructObjectPropertyUInt64 "serial" val

data DeviceToolSerialPropertyInfo
instance AttrInfo DeviceToolSerialPropertyInfo where
    type AttrAllowedOps DeviceToolSerialPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DeviceToolSerialPropertyInfo = (~) Word64
    type AttrBaseTypeConstraint DeviceToolSerialPropertyInfo = IsDeviceTool
    type AttrGetType DeviceToolSerialPropertyInfo = Word64
    type AttrLabel DeviceToolSerialPropertyInfo = "serial"
    type AttrOrigin DeviceToolSerialPropertyInfo = DeviceTool
    attrGet _ = getDeviceToolSerial
    attrSet _ = undefined
    attrConstruct _ = constructDeviceToolSerial
    attrClear _ = undefined

-- VVV Prop "tool-type"
   -- Type: TInterface (Name {namespace = "Gdk", name = "DeviceToolType"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getDeviceToolToolType :: (MonadIO m, IsDeviceTool o) => o -> m Gdk.Enums.DeviceToolType
getDeviceToolToolType obj = liftIO $ getObjectPropertyEnum obj "tool-type"

constructDeviceToolToolType :: (IsDeviceTool o) => Gdk.Enums.DeviceToolType -> IO (GValueConstruct o)
constructDeviceToolToolType val = constructObjectPropertyEnum "tool-type" val

data DeviceToolToolTypePropertyInfo
instance AttrInfo DeviceToolToolTypePropertyInfo where
    type AttrAllowedOps DeviceToolToolTypePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DeviceToolToolTypePropertyInfo = (~) Gdk.Enums.DeviceToolType
    type AttrBaseTypeConstraint DeviceToolToolTypePropertyInfo = IsDeviceTool
    type AttrGetType DeviceToolToolTypePropertyInfo = Gdk.Enums.DeviceToolType
    type AttrLabel DeviceToolToolTypePropertyInfo = "tool-type"
    type AttrOrigin DeviceToolToolTypePropertyInfo = DeviceTool
    attrGet _ = getDeviceToolToolType
    attrSet _ = undefined
    attrConstruct _ = constructDeviceToolToolType
    attrClear _ = undefined

instance O.HasAttributeList DeviceTool
type instance O.AttributeList DeviceTool = DeviceToolAttributeList
type DeviceToolAttributeList = ('[ '("axes", DeviceToolAxesPropertyInfo), '("hardwareId", DeviceToolHardwareIdPropertyInfo), '("serial", DeviceToolSerialPropertyInfo), '("toolType", DeviceToolToolTypePropertyInfo)] :: [(Symbol, *)])

deviceToolAxes :: AttrLabelProxy "axes"
deviceToolAxes = AttrLabelProxy

deviceToolHardwareId :: AttrLabelProxy "hardwareId"
deviceToolHardwareId = AttrLabelProxy

deviceToolSerial :: AttrLabelProxy "serial"
deviceToolSerial = AttrLabelProxy

deviceToolToolType :: AttrLabelProxy "toolType"
deviceToolToolType = AttrLabelProxy

type instance O.SignalList DeviceTool = DeviceToolSignalList
type DeviceToolSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method DeviceTool::get_hardware_id
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "tool", argType = TInterface (Name {namespace = "Gdk", name = "DeviceTool"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkDeviceTool", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_tool_get_hardware_id" gdk_device_tool_get_hardware_id :: 
    Ptr DeviceTool ->                       -- tool : TInterface (Name {namespace = "Gdk", name = "DeviceTool"})
    IO Word64

{- |
Gets the hardware ID of this tool, or 0 if it\'s not known. When
non-zero, the identificator is unique for the given tool model,
meaning that two identical tools will share the same /@hardwareId@/,
but will have different serial numbers (see 'GI.Gdk.Objects.DeviceTool.deviceToolGetSerial').

This is a more concrete (and device specific) method to identify
a 'GI.Gdk.Objects.DeviceTool.DeviceTool' than 'GI.Gdk.Objects.DeviceTool.deviceToolGetToolType', as a tablet
may support multiple devices with the same 'GI.Gdk.Enums.DeviceToolType',
but having different hardware identificators.

@since 3.22
-}
deviceToolGetHardwareId ::
    (B.CallStack.HasCallStack, MonadIO m, IsDeviceTool a) =>
    a
    {- ^ /@tool@/: a 'GI.Gdk.Objects.DeviceTool.DeviceTool' -}
    -> m Word64
    {- ^ __Returns:__ The hardware identificator of this tool. -}
deviceToolGetHardwareId tool = liftIO $ do
    tool' <- unsafeManagedPtrCastPtr tool
    result <- gdk_device_tool_get_hardware_id tool'
    touchManagedPtr tool
    return result

data DeviceToolGetHardwareIdMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsDeviceTool a) => O.MethodInfo DeviceToolGetHardwareIdMethodInfo a signature where
    overloadedMethod _ = deviceToolGetHardwareId

-- method DeviceTool::get_serial
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "tool", argType = TInterface (Name {namespace = "Gdk", name = "DeviceTool"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkDeviceTool", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_tool_get_serial" gdk_device_tool_get_serial :: 
    Ptr DeviceTool ->                       -- tool : TInterface (Name {namespace = "Gdk", name = "DeviceTool"})
    IO Word64

{- |
Gets the serial of this tool, this value can be used to identify a
physical tool (eg. a tablet pen) across program executions.

@since 3.22
-}
deviceToolGetSerial ::
    (B.CallStack.HasCallStack, MonadIO m, IsDeviceTool a) =>
    a
    {- ^ /@tool@/: a 'GI.Gdk.Objects.DeviceTool.DeviceTool' -}
    -> m Word64
    {- ^ __Returns:__ The serial ID for this tool -}
deviceToolGetSerial tool = liftIO $ do
    tool' <- unsafeManagedPtrCastPtr tool
    result <- gdk_device_tool_get_serial tool'
    touchManagedPtr tool
    return result

data DeviceToolGetSerialMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsDeviceTool a) => O.MethodInfo DeviceToolGetSerialMethodInfo a signature where
    overloadedMethod _ = deviceToolGetSerial

-- method DeviceTool::get_tool_type
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "tool", argType = TInterface (Name {namespace = "Gdk", name = "DeviceTool"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkDeviceTool", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gdk", name = "DeviceToolType"}))
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_tool_get_tool_type" gdk_device_tool_get_tool_type :: 
    Ptr DeviceTool ->                       -- tool : TInterface (Name {namespace = "Gdk", name = "DeviceTool"})
    IO CUInt

{- |
Gets the 'GI.Gdk.Enums.DeviceToolType' of the tool.

@since 3.22
-}
deviceToolGetToolType ::
    (B.CallStack.HasCallStack, MonadIO m, IsDeviceTool a) =>
    a
    {- ^ /@tool@/: a 'GI.Gdk.Objects.DeviceTool.DeviceTool' -}
    -> m Gdk.Enums.DeviceToolType
    {- ^ __Returns:__ The physical type for this tool. This can be used to figure out what
sort of pen is being used, such as an airbrush or a pencil. -}
deviceToolGetToolType tool = liftIO $ do
    tool' <- unsafeManagedPtrCastPtr tool
    result <- gdk_device_tool_get_tool_type tool'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr tool
    return result'

data DeviceToolGetToolTypeMethodInfo
instance (signature ~ (m Gdk.Enums.DeviceToolType), MonadIO m, IsDeviceTool a) => O.MethodInfo DeviceToolGetToolTypeMethodInfo a signature where
    overloadedMethod _ = deviceToolGetToolType