{- |
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 all or part of a window becomes visible and needs to be
redrawn.
-}

module GI.Gdk.Structs.EventExpose
    ( 

-- * Exported types
    EventExpose(..)                         ,
    newZeroEventExpose                      ,
    noEventExpose                           ,


 -- * Properties
-- ** area #attr:area#
    eventExpose_area                        ,
    getEventExposeArea                      ,


-- ** count #attr:count#
    eventExpose_count                       ,
    getEventExposeCount                     ,
    setEventExposeCount                     ,


-- ** region #attr:region#
    clearEventExposeRegion                  ,
    eventExpose_region                      ,
    getEventExposeRegion                    ,
    setEventExposeRegion                    ,


-- ** sendEvent #attr:sendEvent#
    eventExpose_sendEvent                   ,
    getEventExposeSendEvent                 ,
    setEventExposeSendEvent                 ,


-- ** type #attr:type#
    eventExpose_type                        ,
    getEventExposeType                      ,
    setEventExposeType                      ,


-- ** window #attr:window#
    clearEventExposeWindow                  ,
    eventExpose_window                      ,
    getEventExposeWindow                    ,
    setEventExposeWindow                    ,




    ) 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.Cairo.Structs.Region as Cairo.Region
import {-# SOURCE #-} qualified GI.Gdk.Enums as Gdk.Enums
import {-# SOURCE #-} qualified GI.Gdk.Objects.Window as Gdk.Window
import {-# SOURCE #-} qualified GI.Gdk.Structs.Rectangle as Gdk.Rectangle

newtype EventExpose = EventExpose (ManagedPtr EventExpose)
instance WrappedPtr EventExpose where
    wrappedPtrCalloc = callocBytes 56
    wrappedPtrCopy = \p -> withManagedPtr p (copyBytes 56 >=> wrapPtr EventExpose)
    wrappedPtrFree = Just ptr_to_g_free

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

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


noEventExpose :: Maybe EventExpose
noEventExpose = Nothing

getEventExposeType :: MonadIO m => EventExpose -> m Gdk.Enums.EventType
getEventExposeType s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO CUInt
    let val' = (toEnum . fromIntegral) val
    return val'

setEventExposeType :: MonadIO m => EventExpose -> Gdk.Enums.EventType -> m ()
setEventExposeType s val = liftIO $ withManagedPtr s $ \ptr -> do
    let val' = (fromIntegral . fromEnum) val
    poke (ptr `plusPtr` 0) (val' :: CUInt)

data EventExposeTypeFieldInfo
instance AttrInfo EventExposeTypeFieldInfo where
    type AttrAllowedOps EventExposeTypeFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint EventExposeTypeFieldInfo = (~) Gdk.Enums.EventType
    type AttrBaseTypeConstraint EventExposeTypeFieldInfo = (~) EventExpose
    type AttrGetType EventExposeTypeFieldInfo = Gdk.Enums.EventType
    type AttrLabel EventExposeTypeFieldInfo = "type"
    type AttrOrigin EventExposeTypeFieldInfo = EventExpose
    attrGet _ = getEventExposeType
    attrSet _ = setEventExposeType
    attrConstruct = undefined
    attrClear _ = undefined

eventExpose_type :: AttrLabelProxy "type"
eventExpose_type = AttrLabelProxy


getEventExposeWindow :: MonadIO m => EventExpose -> m (Maybe Gdk.Window.Window)
getEventExposeWindow 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

setEventExposeWindow :: MonadIO m => EventExpose -> Ptr Gdk.Window.Window -> m ()
setEventExposeWindow s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (val :: Ptr Gdk.Window.Window)

clearEventExposeWindow :: MonadIO m => EventExpose -> m ()
clearEventExposeWindow s = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (FP.nullPtr :: Ptr Gdk.Window.Window)

data EventExposeWindowFieldInfo
instance AttrInfo EventExposeWindowFieldInfo where
    type AttrAllowedOps EventExposeWindowFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint EventExposeWindowFieldInfo = (~) (Ptr Gdk.Window.Window)
    type AttrBaseTypeConstraint EventExposeWindowFieldInfo = (~) EventExpose
    type AttrGetType EventExposeWindowFieldInfo = Maybe Gdk.Window.Window
    type AttrLabel EventExposeWindowFieldInfo = "window"
    type AttrOrigin EventExposeWindowFieldInfo = EventExpose
    attrGet _ = getEventExposeWindow
    attrSet _ = setEventExposeWindow
    attrConstruct = undefined
    attrClear _ = clearEventExposeWindow

eventExpose_window :: AttrLabelProxy "window"
eventExpose_window = AttrLabelProxy


getEventExposeSendEvent :: MonadIO m => EventExpose -> m Int8
getEventExposeSendEvent s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO Int8
    return val

setEventExposeSendEvent :: MonadIO m => EventExpose -> Int8 -> m ()
setEventExposeSendEvent s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 16) (val :: Int8)

data EventExposeSendEventFieldInfo
instance AttrInfo EventExposeSendEventFieldInfo where
    type AttrAllowedOps EventExposeSendEventFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint EventExposeSendEventFieldInfo = (~) Int8
    type AttrBaseTypeConstraint EventExposeSendEventFieldInfo = (~) EventExpose
    type AttrGetType EventExposeSendEventFieldInfo = Int8
    type AttrLabel EventExposeSendEventFieldInfo = "send_event"
    type AttrOrigin EventExposeSendEventFieldInfo = EventExpose
    attrGet _ = getEventExposeSendEvent
    attrSet _ = setEventExposeSendEvent
    attrConstruct = undefined
    attrClear _ = undefined

eventExpose_sendEvent :: AttrLabelProxy "sendEvent"
eventExpose_sendEvent = AttrLabelProxy


getEventExposeArea :: MonadIO m => EventExpose -> m Gdk.Rectangle.Rectangle
getEventExposeArea s = liftIO $ withManagedPtr s $ \ptr -> do
    let val = ptr `plusPtr` 20 :: (Ptr Gdk.Rectangle.Rectangle)
    val' <- (newBoxed Gdk.Rectangle.Rectangle) val
    return val'

data EventExposeAreaFieldInfo
instance AttrInfo EventExposeAreaFieldInfo where
    type AttrAllowedOps EventExposeAreaFieldInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint EventExposeAreaFieldInfo = (~) (Ptr Gdk.Rectangle.Rectangle)
    type AttrBaseTypeConstraint EventExposeAreaFieldInfo = (~) EventExpose
    type AttrGetType EventExposeAreaFieldInfo = Gdk.Rectangle.Rectangle
    type AttrLabel EventExposeAreaFieldInfo = "area"
    type AttrOrigin EventExposeAreaFieldInfo = EventExpose
    attrGet _ = getEventExposeArea
    attrSet _ = undefined
    attrConstruct = undefined
    attrClear _ = undefined

eventExpose_area :: AttrLabelProxy "area"
eventExpose_area = AttrLabelProxy


getEventExposeRegion :: MonadIO m => EventExpose -> m (Maybe Cairo.Region.Region)
getEventExposeRegion s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 40) :: IO (Ptr Cairo.Region.Region)
    result <- SP.convertIfNonNull val $ \val' -> do
        val'' <- (newBoxed Cairo.Region.Region) val'
        return val''
    return result

setEventExposeRegion :: MonadIO m => EventExpose -> Ptr Cairo.Region.Region -> m ()
setEventExposeRegion s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 40) (val :: Ptr Cairo.Region.Region)

clearEventExposeRegion :: MonadIO m => EventExpose -> m ()
clearEventExposeRegion s = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 40) (FP.nullPtr :: Ptr Cairo.Region.Region)

data EventExposeRegionFieldInfo
instance AttrInfo EventExposeRegionFieldInfo where
    type AttrAllowedOps EventExposeRegionFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint EventExposeRegionFieldInfo = (~) (Ptr Cairo.Region.Region)
    type AttrBaseTypeConstraint EventExposeRegionFieldInfo = (~) EventExpose
    type AttrGetType EventExposeRegionFieldInfo = Maybe Cairo.Region.Region
    type AttrLabel EventExposeRegionFieldInfo = "region"
    type AttrOrigin EventExposeRegionFieldInfo = EventExpose
    attrGet _ = getEventExposeRegion
    attrSet _ = setEventExposeRegion
    attrConstruct = undefined
    attrClear _ = clearEventExposeRegion

eventExpose_region :: AttrLabelProxy "region"
eventExpose_region = AttrLabelProxy


getEventExposeCount :: MonadIO m => EventExpose -> m Int32
getEventExposeCount s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 48) :: IO Int32
    return val

setEventExposeCount :: MonadIO m => EventExpose -> Int32 -> m ()
setEventExposeCount s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 48) (val :: Int32)

data EventExposeCountFieldInfo
instance AttrInfo EventExposeCountFieldInfo where
    type AttrAllowedOps EventExposeCountFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint EventExposeCountFieldInfo = (~) Int32
    type AttrBaseTypeConstraint EventExposeCountFieldInfo = (~) EventExpose
    type AttrGetType EventExposeCountFieldInfo = Int32
    type AttrLabel EventExposeCountFieldInfo = "count"
    type AttrOrigin EventExposeCountFieldInfo = EventExpose
    attrGet _ = getEventExposeCount
    attrSet _ = setEventExposeCount
    attrConstruct = undefined
    attrClear _ = undefined

eventExpose_count :: AttrLabelProxy "count"
eventExpose_count = AttrLabelProxy



instance O.HasAttributeList EventExpose
type instance O.AttributeList EventExpose = EventExposeAttributeList
type EventExposeAttributeList = ('[ '("type", EventExposeTypeFieldInfo), '("window", EventExposeWindowFieldInfo), '("sendEvent", EventExposeSendEventFieldInfo), '("area", EventExposeAreaFieldInfo), '("region", EventExposeRegionFieldInfo), '("count", EventExposeCountFieldInfo)] :: [(Symbol, *)])

type family ResolveEventExposeMethod (t :: Symbol) (o :: *) :: * where
    ResolveEventExposeMethod l o = O.MethodResolutionFailed l o

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

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