{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

Generated when the window visibility status has changed.
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.Gdk.Structs.EventVisibility
    (

-- * Exported types
    EventVisibility(..)                     ,
    newZeroEventVisibility                  ,
    noEventVisibility                       ,


 -- * Properties
-- ** sendEvent #attr:sendEvent#
{- | 'True' if the event was sent explicitly.
-}
#if ENABLE_OVERLOADING
    eventVisibility_sendEvent               ,
#endif
    getEventVisibilitySendEvent             ,
    setEventVisibilitySendEvent             ,


-- ** state #attr:state#
{- | the new visibility state ('GI.Gdk.Enums.VisibilityStateFullyObscured',
  'GI.Gdk.Enums.VisibilityStatePartial' or 'GI.Gdk.Enums.VisibilityStateUnobscured').
-}
#if ENABLE_OVERLOADING
    eventVisibility_state                   ,
#endif
    getEventVisibilityState                 ,
    setEventVisibilityState                 ,


-- ** type #attr:type#
{- | the type of the event ('GI.Gdk.Enums.EventTypeVisibilityNotify').
-}
#if ENABLE_OVERLOADING
    eventVisibility_type                    ,
#endif
    getEventVisibilityType                  ,
    setEventVisibilityType                  ,


-- ** window #attr:window#
{- | the window which received the event.
-}
    clearEventVisibilityWindow              ,
#if ENABLE_OVERLOADING
    eventVisibility_window                  ,
#endif
    getEventVisibilityWindow                ,
    setEventVisibilityWindow                ,




    ) 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.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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import {-# SOURCE #-} qualified GI.Gdk.Enums as Gdk.Enums
import {-# SOURCE #-} qualified GI.Gdk.Objects.Window as Gdk.Window

-- | Memory-managed wrapper type.
newtype EventVisibility = EventVisibility (ManagedPtr EventVisibility)
instance WrappedPtr EventVisibility where
    wrappedPtrCalloc = callocBytes 24
    wrappedPtrCopy = \p -> withManagedPtr p (copyBytes 24 >=> wrapPtr EventVisibility)
    wrappedPtrFree = Just ptr_to_g_free

-- | Construct a `EventVisibility` struct initialized to zero.
newZeroEventVisibility :: MonadIO m => m EventVisibility
newZeroEventVisibility = liftIO $ wrappedPtrCalloc >>= wrapPtr EventVisibility

instance tag ~ 'AttrSet => Constructible EventVisibility tag where
    new _ attrs = do
        o <- newZeroEventVisibility
        GI.Attributes.set o attrs
        return o


-- | A convenience alias for `Nothing` :: `Maybe` `EventVisibility`.
noEventVisibility :: Maybe EventVisibility
noEventVisibility = Nothing

{- |
Get the value of the “@type@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' eventVisibility #type
@
-}
getEventVisibilityType :: MonadIO m => EventVisibility -> m Gdk.Enums.EventType
getEventVisibilityType s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO CUInt
    let val' = (toEnum . fromIntegral) val
    return val'

{- |
Set the value of the “@type@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' eventVisibility [ #type 'Data.GI.Base.Attributes.:=' value ]
@
-}
setEventVisibilityType :: MonadIO m => EventVisibility -> Gdk.Enums.EventType -> m ()
setEventVisibilityType s val = liftIO $ withManagedPtr s $ \ptr -> do
    let val' = (fromIntegral . fromEnum) val
    poke (ptr `plusPtr` 0) (val' :: CUInt)

#if ENABLE_OVERLOADING
data EventVisibilityTypeFieldInfo
instance AttrInfo EventVisibilityTypeFieldInfo where
    type AttrAllowedOps EventVisibilityTypeFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint EventVisibilityTypeFieldInfo = (~) Gdk.Enums.EventType
    type AttrBaseTypeConstraint EventVisibilityTypeFieldInfo = (~) EventVisibility
    type AttrGetType EventVisibilityTypeFieldInfo = Gdk.Enums.EventType
    type AttrLabel EventVisibilityTypeFieldInfo = "type"
    type AttrOrigin EventVisibilityTypeFieldInfo = EventVisibility
    attrGet _ = getEventVisibilityType
    attrSet _ = setEventVisibilityType
    attrConstruct = undefined
    attrClear _ = undefined

eventVisibility_type :: AttrLabelProxy "type"
eventVisibility_type = AttrLabelProxy

#endif


{- |
Get the value of the “@window@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' eventVisibility #window
@
-}
getEventVisibilityWindow :: MonadIO m => EventVisibility -> m (Maybe Gdk.Window.Window)
getEventVisibilityWindow s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO (Ptr Gdk.Window.Window)
    result <- SP.convertIfNonNull val $ \val' -> do
        val'' <- (newObject Gdk.Window.Window) val'
        return val''
    return result

{- |
Set the value of the “@window@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' eventVisibility [ #window 'Data.GI.Base.Attributes.:=' value ]
@
-}
setEventVisibilityWindow :: MonadIO m => EventVisibility -> Ptr Gdk.Window.Window -> m ()
setEventVisibilityWindow s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (val :: Ptr Gdk.Window.Window)

{- |
Set the value of the “@window@” field to `Nothing`.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.clear' #window
@
-}
clearEventVisibilityWindow :: MonadIO m => EventVisibility -> m ()
clearEventVisibilityWindow s = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (FP.nullPtr :: Ptr Gdk.Window.Window)

#if ENABLE_OVERLOADING
data EventVisibilityWindowFieldInfo
instance AttrInfo EventVisibilityWindowFieldInfo where
    type AttrAllowedOps EventVisibilityWindowFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint EventVisibilityWindowFieldInfo = (~) (Ptr Gdk.Window.Window)
    type AttrBaseTypeConstraint EventVisibilityWindowFieldInfo = (~) EventVisibility
    type AttrGetType EventVisibilityWindowFieldInfo = Maybe Gdk.Window.Window
    type AttrLabel EventVisibilityWindowFieldInfo = "window"
    type AttrOrigin EventVisibilityWindowFieldInfo = EventVisibility
    attrGet _ = getEventVisibilityWindow
    attrSet _ = setEventVisibilityWindow
    attrConstruct = undefined
    attrClear _ = clearEventVisibilityWindow

eventVisibility_window :: AttrLabelProxy "window"
eventVisibility_window = AttrLabelProxy

#endif


{- |
Get the value of the “@send_event@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' eventVisibility #sendEvent
@
-}
getEventVisibilitySendEvent :: MonadIO m => EventVisibility -> m Int8
getEventVisibilitySendEvent s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO Int8
    return val

{- |
Set the value of the “@send_event@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' eventVisibility [ #sendEvent 'Data.GI.Base.Attributes.:=' value ]
@
-}
setEventVisibilitySendEvent :: MonadIO m => EventVisibility -> Int8 -> m ()
setEventVisibilitySendEvent s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 16) (val :: Int8)

#if ENABLE_OVERLOADING
data EventVisibilitySendEventFieldInfo
instance AttrInfo EventVisibilitySendEventFieldInfo where
    type AttrAllowedOps EventVisibilitySendEventFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint EventVisibilitySendEventFieldInfo = (~) Int8
    type AttrBaseTypeConstraint EventVisibilitySendEventFieldInfo = (~) EventVisibility
    type AttrGetType EventVisibilitySendEventFieldInfo = Int8
    type AttrLabel EventVisibilitySendEventFieldInfo = "send_event"
    type AttrOrigin EventVisibilitySendEventFieldInfo = EventVisibility
    attrGet _ = getEventVisibilitySendEvent
    attrSet _ = setEventVisibilitySendEvent
    attrConstruct = undefined
    attrClear _ = undefined

eventVisibility_sendEvent :: AttrLabelProxy "sendEvent"
eventVisibility_sendEvent = AttrLabelProxy

#endif


{- |
Get the value of the “@state@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' eventVisibility #state
@
-}
getEventVisibilityState :: MonadIO m => EventVisibility -> m Gdk.Enums.VisibilityState
getEventVisibilityState s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 20) :: IO CUInt
    let val' = (toEnum . fromIntegral) val
    return val'

{- |
Set the value of the “@state@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' eventVisibility [ #state 'Data.GI.Base.Attributes.:=' value ]
@
-}
setEventVisibilityState :: MonadIO m => EventVisibility -> Gdk.Enums.VisibilityState -> m ()
setEventVisibilityState s val = liftIO $ withManagedPtr s $ \ptr -> do
    let val' = (fromIntegral . fromEnum) val
    poke (ptr `plusPtr` 20) (val' :: CUInt)

#if ENABLE_OVERLOADING
data EventVisibilityStateFieldInfo
instance AttrInfo EventVisibilityStateFieldInfo where
    type AttrAllowedOps EventVisibilityStateFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint EventVisibilityStateFieldInfo = (~) Gdk.Enums.VisibilityState
    type AttrBaseTypeConstraint EventVisibilityStateFieldInfo = (~) EventVisibility
    type AttrGetType EventVisibilityStateFieldInfo = Gdk.Enums.VisibilityState
    type AttrLabel EventVisibilityStateFieldInfo = "state"
    type AttrOrigin EventVisibilityStateFieldInfo = EventVisibility
    attrGet _ = getEventVisibilityState
    attrSet _ = setEventVisibilityState
    attrConstruct = undefined
    attrClear _ = undefined

eventVisibility_state :: AttrLabelProxy "state"
eventVisibility_state = AttrLabelProxy

#endif



#if ENABLE_OVERLOADING
instance O.HasAttributeList EventVisibility
type instance O.AttributeList EventVisibility = EventVisibilityAttributeList
type EventVisibilityAttributeList = ('[ '("type", EventVisibilityTypeFieldInfo), '("window", EventVisibilityWindowFieldInfo), '("sendEvent", EventVisibilitySendEventFieldInfo), '("state", EventVisibilityStateFieldInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
type family ResolveEventVisibilityMethod (t :: Symbol) (o :: *) :: * where
    ResolveEventVisibilityMethod l o = O.MethodResolutionFailed l o

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

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

#endif