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

-- * Exported types
    Visual(..)                              ,
    VisualK                                 ,
    toVisual                                ,
    noVisual                                ,


 -- * Methods
-- ** visualGetBest
    visualGetBest                           ,


-- ** visualGetBestDepth
    visualGetBestDepth                      ,


-- ** visualGetBestType
    visualGetBestType                       ,


-- ** visualGetBestWithBoth
    visualGetBestWithBoth                   ,


-- ** visualGetBestWithDepth
    visualGetBestWithDepth                  ,


-- ** visualGetBestWithType
    visualGetBestWithType                   ,


-- ** visualGetBitsPerRgb
    visualGetBitsPerRgb                     ,


-- ** visualGetBluePixelDetails
    visualGetBluePixelDetails               ,


-- ** visualGetByteOrder
    visualGetByteOrder                      ,


-- ** visualGetColormapSize
    visualGetColormapSize                   ,


-- ** visualGetDepth
    visualGetDepth                          ,


-- ** visualGetGreenPixelDetails
    visualGetGreenPixelDetails              ,


-- ** visualGetRedPixelDetails
    visualGetRedPixelDetails                ,


-- ** visualGetScreen
    visualGetScreen                         ,


-- ** visualGetSystem
    visualGetSystem                         ,


-- ** visualGetVisualType
    visualGetVisualType                     ,




    ) 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

newtype Visual = Visual (ForeignPtr Visual)
foreign import ccall "gdk_visual_get_type"
    c_gdk_visual_get_type :: IO GType

type instance ParentTypes Visual = VisualParentTypes
type VisualParentTypes = '[GObject.Object]

instance GObject Visual where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_gdk_visual_get_type
    

class GObject o => VisualK o
instance (GObject o, IsDescendantOf Visual o) => VisualK o

toVisual :: VisualK o => o -> IO Visual
toVisual = unsafeCastTo Visual

noVisual :: Maybe Visual
noVisual = Nothing

type instance AttributeList Visual = VisualAttributeList
type VisualAttributeList = ('[ ] :: [(Symbol, *)])

type instance SignalList Visual = VisualSignalList
type VisualSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method Visual::get_bits_per_rgb
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False

foreign import ccall "gdk_visual_get_bits_per_rgb" gdk_visual_get_bits_per_rgb :: 
    Ptr Visual ->                           -- _obj : TInterface "Gdk" "Visual"
    IO Int32


visualGetBitsPerRgb ::
    (MonadIO m, VisualK a) =>
    a ->                                    -- _obj
    m Int32
visualGetBitsPerRgb _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_visual_get_bits_per_rgb _obj'
    touchManagedPtr _obj
    return result

-- method Visual::get_blue_pixel_details
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "mask", argType = TBasicType TUInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "shift", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "precision", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gdk_visual_get_blue_pixel_details" gdk_visual_get_blue_pixel_details :: 
    Ptr Visual ->                           -- _obj : TInterface "Gdk" "Visual"
    Ptr Word32 ->                           -- mask : TBasicType TUInt32
    Ptr Int32 ->                            -- shift : TBasicType TInt32
    Ptr Int32 ->                            -- precision : TBasicType TInt32
    IO ()


visualGetBluePixelDetails ::
    (MonadIO m, VisualK a) =>
    a ->                                    -- _obj
    m (Word32,Int32,Int32)
visualGetBluePixelDetails _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    mask <- allocMem :: IO (Ptr Word32)
    shift <- allocMem :: IO (Ptr Int32)
    precision <- allocMem :: IO (Ptr Int32)
    gdk_visual_get_blue_pixel_details _obj' mask shift precision
    mask' <- peek mask
    shift' <- peek shift
    precision' <- peek precision
    touchManagedPtr _obj
    freeMem mask
    freeMem shift
    freeMem precision
    return (mask', shift', precision')

-- method Visual::get_byte_order
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "ByteOrder"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_visual_get_byte_order" gdk_visual_get_byte_order :: 
    Ptr Visual ->                           -- _obj : TInterface "Gdk" "Visual"
    IO CUInt


visualGetByteOrder ::
    (MonadIO m, VisualK a) =>
    a ->                                    -- _obj
    m ByteOrder
visualGetByteOrder _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_visual_get_byte_order _obj'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr _obj
    return result'

-- method Visual::get_colormap_size
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False

foreign import ccall "gdk_visual_get_colormap_size" gdk_visual_get_colormap_size :: 
    Ptr Visual ->                           -- _obj : TInterface "Gdk" "Visual"
    IO Int32


visualGetColormapSize ::
    (MonadIO m, VisualK a) =>
    a ->                                    -- _obj
    m Int32
visualGetColormapSize _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_visual_get_colormap_size _obj'
    touchManagedPtr _obj
    return result

-- method Visual::get_depth
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False

foreign import ccall "gdk_visual_get_depth" gdk_visual_get_depth :: 
    Ptr Visual ->                           -- _obj : TInterface "Gdk" "Visual"
    IO Int32


visualGetDepth ::
    (MonadIO m, VisualK a) =>
    a ->                                    -- _obj
    m Int32
visualGetDepth _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_visual_get_depth _obj'
    touchManagedPtr _obj
    return result

-- method Visual::get_green_pixel_details
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "mask", argType = TBasicType TUInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "shift", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "precision", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gdk_visual_get_green_pixel_details" gdk_visual_get_green_pixel_details :: 
    Ptr Visual ->                           -- _obj : TInterface "Gdk" "Visual"
    Ptr Word32 ->                           -- mask : TBasicType TUInt32
    Ptr Int32 ->                            -- shift : TBasicType TInt32
    Ptr Int32 ->                            -- precision : TBasicType TInt32
    IO ()


visualGetGreenPixelDetails ::
    (MonadIO m, VisualK a) =>
    a ->                                    -- _obj
    m (Word32,Int32,Int32)
visualGetGreenPixelDetails _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    mask <- allocMem :: IO (Ptr Word32)
    shift <- allocMem :: IO (Ptr Int32)
    precision <- allocMem :: IO (Ptr Int32)
    gdk_visual_get_green_pixel_details _obj' mask shift precision
    mask' <- peek mask
    shift' <- peek shift
    precision' <- peek precision
    touchManagedPtr _obj
    freeMem mask
    freeMem shift
    freeMem precision
    return (mask', shift', precision')

-- method Visual::get_red_pixel_details
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "mask", argType = TBasicType TUInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "shift", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "precision", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gdk_visual_get_red_pixel_details" gdk_visual_get_red_pixel_details :: 
    Ptr Visual ->                           -- _obj : TInterface "Gdk" "Visual"
    Ptr Word32 ->                           -- mask : TBasicType TUInt32
    Ptr Int32 ->                            -- shift : TBasicType TInt32
    Ptr Int32 ->                            -- precision : TBasicType TInt32
    IO ()


visualGetRedPixelDetails ::
    (MonadIO m, VisualK a) =>
    a ->                                    -- _obj
    m (Word32,Int32,Int32)
visualGetRedPixelDetails _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    mask <- allocMem :: IO (Ptr Word32)
    shift <- allocMem :: IO (Ptr Int32)
    precision <- allocMem :: IO (Ptr Int32)
    gdk_visual_get_red_pixel_details _obj' mask shift precision
    mask' <- peek mask
    shift' <- peek shift
    precision' <- peek precision
    touchManagedPtr _obj
    freeMem mask
    freeMem shift
    freeMem precision
    return (mask', shift', precision')

-- method Visual::get_screen
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "Screen"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_visual_get_screen" gdk_visual_get_screen :: 
    Ptr Visual ->                           -- _obj : TInterface "Gdk" "Visual"
    IO (Ptr Screen)


visualGetScreen ::
    (MonadIO m, VisualK a) =>
    a ->                                    -- _obj
    m Screen
visualGetScreen _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_visual_get_screen _obj'
    checkUnexpectedReturnNULL "gdk_visual_get_screen" result
    result' <- (newObject Screen) result
    touchManagedPtr _obj
    return result'

-- method Visual::get_visual_type
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Visual", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "VisualType"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_visual_get_visual_type" gdk_visual_get_visual_type :: 
    Ptr Visual ->                           -- _obj : TInterface "Gdk" "Visual"
    IO CUInt


visualGetVisualType ::
    (MonadIO m, VisualK a) =>
    a ->                                    -- _obj
    m VisualType
visualGetVisualType _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_visual_get_visual_type _obj'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr _obj
    return result'

-- method Visual::get_best
-- method type : MemberFunction
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TInterface "Gdk" "Visual"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_visual_get_best" gdk_visual_get_best :: 
    IO (Ptr Visual)


visualGetBest ::
    (MonadIO m) =>
    m Visual
visualGetBest  = liftIO $ do
    result <- gdk_visual_get_best
    checkUnexpectedReturnNULL "gdk_visual_get_best" result
    result' <- (newObject Visual) result
    return result'

-- method Visual::get_best_depth
-- method type : MemberFunction
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False

foreign import ccall "gdk_visual_get_best_depth" gdk_visual_get_best_depth :: 
    IO Int32


visualGetBestDepth ::
    (MonadIO m) =>
    m Int32
visualGetBestDepth  = liftIO $ do
    result <- gdk_visual_get_best_depth
    return result

-- method Visual::get_best_type
-- method type : MemberFunction
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TInterface "Gdk" "VisualType"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_visual_get_best_type" gdk_visual_get_best_type :: 
    IO CUInt


visualGetBestType ::
    (MonadIO m) =>
    m VisualType
visualGetBestType  = liftIO $ do
    result <- gdk_visual_get_best_type
    let result' = (toEnum . fromIntegral) result
    return result'

-- method Visual::get_best_with_both
-- method type : MemberFunction
-- Args : [Arg {argName = "depth", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "visual_type", argType = TInterface "Gdk" "VisualType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "depth", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "visual_type", argType = TInterface "Gdk" "VisualType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "Visual"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_visual_get_best_with_both" gdk_visual_get_best_with_both :: 
    Int32 ->                                -- depth : TBasicType TInt32
    CUInt ->                                -- visual_type : TInterface "Gdk" "VisualType"
    IO (Ptr Visual)


visualGetBestWithBoth ::
    (MonadIO m) =>
    Int32 ->                                -- depth
    VisualType ->                           -- visual_type
    m Visual
visualGetBestWithBoth depth visual_type = liftIO $ do
    let visual_type' = (fromIntegral . fromEnum) visual_type
    result <- gdk_visual_get_best_with_both depth visual_type'
    checkUnexpectedReturnNULL "gdk_visual_get_best_with_both" result
    result' <- (newObject Visual) result
    return result'

-- method Visual::get_best_with_depth
-- method type : MemberFunction
-- Args : [Arg {argName = "depth", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "depth", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "Visual"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_visual_get_best_with_depth" gdk_visual_get_best_with_depth :: 
    Int32 ->                                -- depth : TBasicType TInt32
    IO (Ptr Visual)


visualGetBestWithDepth ::
    (MonadIO m) =>
    Int32 ->                                -- depth
    m Visual
visualGetBestWithDepth depth = liftIO $ do
    result <- gdk_visual_get_best_with_depth depth
    checkUnexpectedReturnNULL "gdk_visual_get_best_with_depth" result
    result' <- (newObject Visual) result
    return result'

-- method Visual::get_best_with_type
-- method type : MemberFunction
-- Args : [Arg {argName = "visual_type", argType = TInterface "Gdk" "VisualType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "visual_type", argType = TInterface "Gdk" "VisualType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "Visual"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_visual_get_best_with_type" gdk_visual_get_best_with_type :: 
    CUInt ->                                -- visual_type : TInterface "Gdk" "VisualType"
    IO (Ptr Visual)


visualGetBestWithType ::
    (MonadIO m) =>
    VisualType ->                           -- visual_type
    m Visual
visualGetBestWithType visual_type = liftIO $ do
    let visual_type' = (fromIntegral . fromEnum) visual_type
    result <- gdk_visual_get_best_with_type visual_type'
    checkUnexpectedReturnNULL "gdk_visual_get_best_with_type" result
    result' <- (newObject Visual) result
    return result'

-- method Visual::get_system
-- method type : MemberFunction
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TInterface "Gdk" "Visual"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_visual_get_system" gdk_visual_get_system :: 
    IO (Ptr Visual)


visualGetSystem ::
    (MonadIO m) =>
    m Visual
visualGetSystem  = liftIO $ do
    result <- gdk_visual_get_system
    checkUnexpectedReturnNULL "gdk_visual_get_system" result
    result' <- (newObject Visual) result
    return result'