#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Atk.Structs.TextRange
(
TextRange(..) ,
newZeroTextRange ,
noTextRange ,
getTextRangeBounds ,
#if ENABLE_OVERLOADING
textRange_bounds ,
#endif
clearTextRangeContent ,
getTextRangeContent ,
setTextRangeContent ,
#if ENABLE_OVERLOADING
textRange_content ,
#endif
getTextRangeEndOffset ,
setTextRangeEndOffset ,
#if ENABLE_OVERLOADING
textRange_endOffset ,
#endif
getTextRangeStartOffset ,
setTextRangeStartOffset ,
#if ENABLE_OVERLOADING
textRange_startOffset ,
#endif
) 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.GClosure as B.GClosure
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.GI.Base.Properties as B.Properties
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 GHC.OverloadedLabels as OL
import {-# SOURCE #-} qualified GI.Atk.Structs.TextRectangle as Atk.TextRectangle
newtype TextRange = TextRange (ManagedPtr TextRange)
foreign import ccall "atk_text_range_get_type" c_atk_text_range_get_type ::
IO GType
instance BoxedObject TextRange where
boxedType _ = c_atk_text_range_get_type
newZeroTextRange :: MonadIO m => m TextRange
newZeroTextRange = liftIO $ callocBoxedBytes 32 >>= wrapBoxed TextRange
instance tag ~ 'AttrSet => Constructible TextRange tag where
new _ attrs = do
o <- newZeroTextRange
GI.Attributes.set o attrs
return o
noTextRange :: Maybe TextRange
noTextRange = Nothing
getTextRangeBounds :: MonadIO m => TextRange -> m Atk.TextRectangle.TextRectangle
getTextRangeBounds s = liftIO $ withManagedPtr s $ \ptr -> do
let val = ptr `plusPtr` 0 :: (Ptr Atk.TextRectangle.TextRectangle)
val' <- (newPtr Atk.TextRectangle.TextRectangle) val
return val'
#if ENABLE_OVERLOADING
data TextRangeBoundsFieldInfo
instance AttrInfo TextRangeBoundsFieldInfo where
type AttrAllowedOps TextRangeBoundsFieldInfo = '[ 'AttrGet]
type AttrSetTypeConstraint TextRangeBoundsFieldInfo = (~) (Ptr Atk.TextRectangle.TextRectangle)
type AttrBaseTypeConstraint TextRangeBoundsFieldInfo = (~) TextRange
type AttrGetType TextRangeBoundsFieldInfo = Atk.TextRectangle.TextRectangle
type AttrLabel TextRangeBoundsFieldInfo = "bounds"
type AttrOrigin TextRangeBoundsFieldInfo = TextRange
attrGet _ = getTextRangeBounds
attrSet _ = undefined
attrConstruct = undefined
attrClear _ = undefined
textRange_bounds :: AttrLabelProxy "bounds"
textRange_bounds = AttrLabelProxy
#endif
getTextRangeStartOffset :: MonadIO m => TextRange -> m Int32
getTextRangeStartOffset s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 16) :: IO Int32
return val
setTextRangeStartOffset :: MonadIO m => TextRange -> Int32 -> m ()
setTextRangeStartOffset s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 16) (val :: Int32)
#if ENABLE_OVERLOADING
data TextRangeStartOffsetFieldInfo
instance AttrInfo TextRangeStartOffsetFieldInfo where
type AttrAllowedOps TextRangeStartOffsetFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint TextRangeStartOffsetFieldInfo = (~) Int32
type AttrBaseTypeConstraint TextRangeStartOffsetFieldInfo = (~) TextRange
type AttrGetType TextRangeStartOffsetFieldInfo = Int32
type AttrLabel TextRangeStartOffsetFieldInfo = "start_offset"
type AttrOrigin TextRangeStartOffsetFieldInfo = TextRange
attrGet _ = getTextRangeStartOffset
attrSet _ = setTextRangeStartOffset
attrConstruct = undefined
attrClear _ = undefined
textRange_startOffset :: AttrLabelProxy "startOffset"
textRange_startOffset = AttrLabelProxy
#endif
getTextRangeEndOffset :: MonadIO m => TextRange -> m Int32
getTextRangeEndOffset s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 20) :: IO Int32
return val
setTextRangeEndOffset :: MonadIO m => TextRange -> Int32 -> m ()
setTextRangeEndOffset s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 20) (val :: Int32)
#if ENABLE_OVERLOADING
data TextRangeEndOffsetFieldInfo
instance AttrInfo TextRangeEndOffsetFieldInfo where
type AttrAllowedOps TextRangeEndOffsetFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint TextRangeEndOffsetFieldInfo = (~) Int32
type AttrBaseTypeConstraint TextRangeEndOffsetFieldInfo = (~) TextRange
type AttrGetType TextRangeEndOffsetFieldInfo = Int32
type AttrLabel TextRangeEndOffsetFieldInfo = "end_offset"
type AttrOrigin TextRangeEndOffsetFieldInfo = TextRange
attrGet _ = getTextRangeEndOffset
attrSet _ = setTextRangeEndOffset
attrConstruct = undefined
attrClear _ = undefined
textRange_endOffset :: AttrLabelProxy "endOffset"
textRange_endOffset = AttrLabelProxy
#endif
getTextRangeContent :: MonadIO m => TextRange -> m (Maybe T.Text)
getTextRangeContent s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 24) :: IO CString
result <- SP.convertIfNonNull val $ \val' -> do
val'' <- cstringToText val'
return val''
return result
setTextRangeContent :: MonadIO m => TextRange -> CString -> m ()
setTextRangeContent s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 24) (val :: CString)
clearTextRangeContent :: MonadIO m => TextRange -> m ()
clearTextRangeContent s = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 24) (FP.nullPtr :: CString)
#if ENABLE_OVERLOADING
data TextRangeContentFieldInfo
instance AttrInfo TextRangeContentFieldInfo where
type AttrAllowedOps TextRangeContentFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint TextRangeContentFieldInfo = (~) CString
type AttrBaseTypeConstraint TextRangeContentFieldInfo = (~) TextRange
type AttrGetType TextRangeContentFieldInfo = Maybe T.Text
type AttrLabel TextRangeContentFieldInfo = "content"
type AttrOrigin TextRangeContentFieldInfo = TextRange
attrGet _ = getTextRangeContent
attrSet _ = setTextRangeContent
attrConstruct = undefined
attrClear _ = clearTextRangeContent
textRange_content :: AttrLabelProxy "content"
textRange_content = AttrLabelProxy
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList TextRange
type instance O.AttributeList TextRange = TextRangeAttributeList
type TextRangeAttributeList = ('[ '("bounds", TextRangeBoundsFieldInfo), '("startOffset", TextRangeStartOffsetFieldInfo), '("endOffset", TextRangeEndOffsetFieldInfo), '("content", TextRangeContentFieldInfo)] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
type family ResolveTextRangeMethod (t :: Symbol) (o :: *) :: * where
ResolveTextRangeMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveTextRangeMethod t TextRange, O.MethodInfo info TextRange p) => OL.IsLabel t (TextRange -> 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