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

    'GI.Atk.Structs.Range.Range' are used on 'GI.Atk.Interfaces.Value.Value', in order to represent the full
    range of a given component (for example an slider or a range
    control), or to define each individual subrange this full range is
    splitted if available. See 'GI.Atk.Interfaces.Value.Value' documentation for further
    details.
    -}

    #define ENABLE_OVERLOADING \
           (!defined(__HADDOCK_VERSION__))

    module GI.Atk.Structs.Range
        (

    -- * Exported types
        Range(..)                               ,
        noRange                                 ,

     -- * Methods
    -- ** copy #method:copy#

    #if ENABLE_OVERLOADING
        RangeCopyMethodInfo                     ,
    #endif
        rangeCopy                               ,

    -- ** free #method:free#

    #if ENABLE_OVERLOADING
        RangeFreeMethodInfo                     ,
    #endif
        rangeFree                               ,

    -- ** getDescription #method:getDescription#

    #if ENABLE_OVERLOADING
        RangeGetDescriptionMethodInfo           ,
    #endif
        rangeGetDescription                     ,

    -- ** getLowerLimit #method:getLowerLimit#

    #if ENABLE_OVERLOADING
        RangeGetLowerLimitMethodInfo            ,
    #endif
        rangeGetLowerLimit                      ,

    -- ** getUpperLimit #method:getUpperLimit#

    #if ENABLE_OVERLOADING
        RangeGetUpperLimitMethodInfo            ,
    #endif
        rangeGetUpperLimit                      ,

    -- ** new #method:new#

        rangeNew                                ,

        ) 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

    -- | Memory-managed wrapper type.
    newtype Range = Range (ManagedPtr Range)
    foreign import ccall "atk_range_get_type" c_atk_range_get_type ::
        IO GType

    instance BoxedObject Range where
        boxedType _ = c_atk_range_get_type

    -- | A convenience alias for `Nothing` :: `Maybe` `Range`.
    noRange :: Maybe Range
    noRange = Nothing

    #if ENABLE_OVERLOADING
    instance O.HasAttributeList Range
    type instance O.AttributeList Range = RangeAttributeList
    type RangeAttributeList = ('[ ] :: [(Symbol, *)])
    #endif

    -- method Range::new
    -- method type : Constructor
    -- Args : [Arg {argCName = "lower_limit", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "inferior limit for this range", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "upper_limit", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "superior limit for this range", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "description", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "human readable description of this range.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Just (TInterface (Name {namespace = "Atk", name = "Range"}))
    -- throws : False
    -- Skip return : False

    foreign import ccall "atk_range_new" atk_range_new ::
        CDouble ->                              -- lower_limit : TBasicType TDouble
        CDouble ->                              -- upper_limit : TBasicType TDouble
        CString ->                              -- description : TBasicType TUTF8
        IO (Ptr Range)

    {- |
    Creates a new 'GI.Atk.Structs.Range.Range'.

    /Since: 2.12/
    -}
    rangeNew ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Double
        {- ^ /@lowerLimit@/: inferior limit for this range -}
        -> Double
        {- ^ /@upperLimit@/: superior limit for this range -}
        -> T.Text
        {- ^ /@description@/: human readable description of this range. -}
        -> m Range
        {- ^ __Returns:__ a new 'GI.Atk.Structs.Range.Range' -}
    rangeNew lowerLimit upperLimit description = liftIO $ do
        let lowerLimit' = realToFrac lowerLimit
        let upperLimit' = realToFrac upperLimit
        description' <- textToCString description
        result <- atk_range_new lowerLimit' upperLimit' description'
        checkUnexpectedReturnNULL "rangeNew" result
        result' <- (wrapBoxed Range) result
        freeMem description'
        return result'

    #if ENABLE_OVERLOADING
    #endif

    -- method Range::copy
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "src", argType = TInterface (Name {namespace = "Atk", name = "Range"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#AtkRange to copy", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Just (TInterface (Name {namespace = "Atk", name = "Range"}))
    -- throws : False
    -- Skip return : False

    foreign import ccall "atk_range_copy" atk_range_copy ::
        Ptr Range ->                            -- src : TInterface (Name {namespace = "Atk", name = "Range"})
        IO (Ptr Range)

    {- |
    Returns a new 'GI.Atk.Structs.Range.Range' that is a exact copy of /@src@/

    /Since: 2.12/
    -}
    rangeCopy ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Range
        {- ^ /@src@/: 'GI.Atk.Structs.Range.Range' to copy -}
        -> m Range
        {- ^ __Returns:__ a new 'GI.Atk.Structs.Range.Range' copy of /@src@/ -}
    rangeCopy src = liftIO $ do
        src' <- unsafeManagedPtrGetPtr src
        result <- atk_range_copy src'
        checkUnexpectedReturnNULL "rangeCopy" result
        result' <- (wrapBoxed Range) result
        touchManagedPtr src
        return result'

    #if ENABLE_OVERLOADING
    data RangeCopyMethodInfo
    instance (signature ~ (m Range), MonadIO m) => O.MethodInfo RangeCopyMethodInfo Range signature where
        overloadedMethod _ = rangeCopy

    #endif

    -- method Range::free
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "range", argType = TInterface (Name {namespace = "Atk", name = "Range"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#AtkRange to free", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "atk_range_free" atk_range_free ::
        Ptr Range ->                            -- range : TInterface (Name {namespace = "Atk", name = "Range"})
        IO ()

    {- |
    Free /@range@/

    /Since: 2.12/
    -}
    rangeFree ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Range
        {- ^ /@range@/: 'GI.Atk.Structs.Range.Range' to free -}
        -> m ()
    rangeFree range = liftIO $ do
        range' <- unsafeManagedPtrGetPtr range
        atk_range_free range'
        touchManagedPtr range
        return ()

    #if ENABLE_OVERLOADING
    data RangeFreeMethodInfo
    instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RangeFreeMethodInfo Range signature where
        overloadedMethod _ = rangeFree

    #endif

    -- method Range::get_description
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "range", argType = TInterface (Name {namespace = "Atk", name = "Range"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkRange", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Just (TBasicType TUTF8)
    -- throws : False
    -- Skip return : False

    foreign import ccall "atk_range_get_description" atk_range_get_description ::
        Ptr Range ->                            -- range : TInterface (Name {namespace = "Atk", name = "Range"})
        IO CString

    {- |
    Returns the human readable description of /@range@/

    /Since: 2.12/
    -}
    rangeGetDescription ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Range
        {- ^ /@range@/: an 'GI.Atk.Structs.Range.Range' -}
        -> m T.Text
        {- ^ __Returns:__ the human-readable description of /@range@/ -}
    rangeGetDescription range = liftIO $ do
        range' <- unsafeManagedPtrGetPtr range
        result <- atk_range_get_description range'
        checkUnexpectedReturnNULL "rangeGetDescription" result
        result' <- cstringToText result
        touchManagedPtr range
        return result'

    #if ENABLE_OVERLOADING
    data RangeGetDescriptionMethodInfo
    instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo RangeGetDescriptionMethodInfo Range signature where
        overloadedMethod _ = rangeGetDescription

    #endif

    -- method Range::get_lower_limit
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "range", argType = TInterface (Name {namespace = "Atk", name = "Range"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkRange", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Just (TBasicType TDouble)
    -- throws : False
    -- Skip return : False

    foreign import ccall "atk_range_get_lower_limit" atk_range_get_lower_limit ::
        Ptr Range ->                            -- range : TInterface (Name {namespace = "Atk", name = "Range"})
        IO CDouble

    {- |
    Returns the lower limit of /@range@/

    /Since: 2.12/
    -}
    rangeGetLowerLimit ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Range
        {- ^ /@range@/: an 'GI.Atk.Structs.Range.Range' -}
        -> m Double
        {- ^ __Returns:__ the lower limit of /@range@/ -}
    rangeGetLowerLimit range = liftIO $ do
        range' <- unsafeManagedPtrGetPtr range
        result <- atk_range_get_lower_limit range'
        let result' = realToFrac result
        touchManagedPtr range
        return result'

    #if ENABLE_OVERLOADING
    data RangeGetLowerLimitMethodInfo
    instance (signature ~ (m Double), MonadIO m) => O.MethodInfo RangeGetLowerLimitMethodInfo Range signature where
        overloadedMethod _ = rangeGetLowerLimit

    #endif

    -- method Range::get_upper_limit
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "range", argType = TInterface (Name {namespace = "Atk", name = "Range"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkRange", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Just (TBasicType TDouble)
    -- throws : False
    -- Skip return : False

    foreign import ccall "atk_range_get_upper_limit" atk_range_get_upper_limit ::
        Ptr Range ->                            -- range : TInterface (Name {namespace = "Atk", name = "Range"})
        IO CDouble

    {- |
    Returns the upper limit of /@range@/

    /Since: 2.12/
    -}
    rangeGetUpperLimit ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Range
        {- ^ /@range@/: an 'GI.Atk.Structs.Range.Range' -}
        -> m Double
        {- ^ __Returns:__ the upper limit of /@range@/ -}
    rangeGetUpperLimit range = liftIO $ do
        range' <- unsafeManagedPtrGetPtr range
        result <- atk_range_get_upper_limit range'
        let result' = realToFrac result
        touchManagedPtr range
        return result'

    #if ENABLE_OVERLOADING
    data RangeGetUpperLimitMethodInfo
    instance (signature ~ (m Double), MonadIO m) => O.MethodInfo RangeGetUpperLimitMethodInfo Range signature where
        overloadedMethod _ = rangeGetUpperLimit

    #endif

    #if ENABLE_OVERLOADING
    type family ResolveRangeMethod (t :: Symbol) (o :: *) :: * where
        ResolveRangeMethod "copy" o = RangeCopyMethodInfo
        ResolveRangeMethod "free" o = RangeFreeMethodInfo
        ResolveRangeMethod "getDescription" o = RangeGetDescriptionMethodInfo
        ResolveRangeMethod "getLowerLimit" o = RangeGetLowerLimitMethodInfo
        ResolveRangeMethod "getUpperLimit" o = RangeGetUpperLimitMethodInfo
        ResolveRangeMethod l o = O.MethodResolutionFailed l o

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

    #if MIN_VERSION_base(4,9,0)
    instance (info ~ ResolveRangeMethod t Range, O.MethodInfo info Range p) => O.IsLabel t (Range -> 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