{-# LANGUAGE CPP, FlexibleContexts, FlexibleInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, ScopedTypeVariables, TypeSynonymInstances, UndecidableInstances #-}
#if !MIN_VERSION_base(4,8,0)
{-# LANGUAGE OverlappingInstances #-}
#endif

---------- GENERATED FILE, EDITS WILL BE LOST ----------

module Graphics.UI.Qtah.Generated.Widgets.QGraphicsPolygonItem (
  castQGraphicsPolygonItemToQAbstractGraphicsShapeItem,
  castQAbstractGraphicsShapeItemToQGraphicsPolygonItem,
  castQGraphicsPolygonItemToQGraphicsItem,
  castQGraphicsItemToQGraphicsPolygonItem,
  QGraphicsPolygonItemValue (..),
  QGraphicsPolygonItemConstPtr (..),
  QGraphicsPolygonItemPtr (..),
  QGraphicsPolygonItemConst (..),
  castQGraphicsPolygonItemToConst,
  QGraphicsPolygonItem (..),
  castQGraphicsPolygonItemToNonconst,
  new,
  QGraphicsPolygonItemSuper (..),
  QGraphicsPolygonItemSuperConst (..),
  ) where

import qualified Foreign as HoppyF
import qualified Foreign.Hoppy.Runtime as HoppyFHR
import {-# SOURCE #-} qualified Graphics.UI.Qtah.Generated.Widgets.QAbstractGraphicsShapeItem as M164
import {-# SOURCE #-} qualified Graphics.UI.Qtah.Generated.Widgets.QGraphicsItem as M202
import Prelude (($), (.), (==))
import qualified Prelude as HoppyP

foreign import ccall "genpop__QGraphicsPolygonItem_new" new' ::  HoppyP.IO (HoppyF.Ptr QGraphicsPolygonItem)
foreign import ccall "gencast__QGraphicsPolygonItem__QAbstractGraphicsShapeItem" castQGraphicsPolygonItemToQAbstractGraphicsShapeItem :: HoppyF.Ptr QGraphicsPolygonItemConst -> HoppyF.Ptr M164.QAbstractGraphicsShapeItemConst
foreign import ccall "gencast__QAbstractGraphicsShapeItem__QGraphicsPolygonItem" castQAbstractGraphicsShapeItemToQGraphicsPolygonItem :: HoppyF.Ptr M164.QAbstractGraphicsShapeItemConst -> HoppyF.Ptr QGraphicsPolygonItemConst
foreign import ccall "gencast__QGraphicsPolygonItem__QGraphicsItem" castQGraphicsPolygonItemToQGraphicsItem :: HoppyF.Ptr QGraphicsPolygonItemConst -> HoppyF.Ptr M202.QGraphicsItemConst
foreign import ccall "gencast__QGraphicsItem__QGraphicsPolygonItem" castQGraphicsItemToQGraphicsPolygonItem :: HoppyF.Ptr M202.QGraphicsItemConst -> HoppyF.Ptr QGraphicsPolygonItemConst
foreign import ccall "gendel__QGraphicsPolygonItem" delete'QGraphicsPolygonItem :: HoppyF.Ptr QGraphicsPolygonItemConst -> HoppyP.IO ()
foreign import ccall "&gendel__QGraphicsPolygonItem" deletePtr'QGraphicsPolygonItem :: HoppyF.FunPtr (HoppyF.Ptr QGraphicsPolygonItemConst -> HoppyP.IO ())

class QGraphicsPolygonItemValue a where
  withQGraphicsPolygonItemPtr :: a -> (QGraphicsPolygonItemConst -> HoppyP.IO b) -> HoppyP.IO b

#if MIN_VERSION_base(4,8,0)
instance {-# OVERLAPPABLE #-} QGraphicsPolygonItemConstPtr a => QGraphicsPolygonItemValue a where
#else
instance QGraphicsPolygonItemConstPtr a => QGraphicsPolygonItemValue a where
#endif
  withQGraphicsPolygonItemPtr = HoppyP.flip ($) . toQGraphicsPolygonItemConst

class (M164.QAbstractGraphicsShapeItemConstPtr this) => QGraphicsPolygonItemConstPtr this where
  toQGraphicsPolygonItemConst :: this -> QGraphicsPolygonItemConst

class (QGraphicsPolygonItemConstPtr this, M164.QAbstractGraphicsShapeItemPtr this) => QGraphicsPolygonItemPtr this where
  toQGraphicsPolygonItem :: this -> QGraphicsPolygonItem

data QGraphicsPolygonItemConst =
    QGraphicsPolygonItemConst (HoppyF.Ptr QGraphicsPolygonItemConst)
  | QGraphicsPolygonItemConstGc (HoppyF.ForeignPtr ()) (HoppyF.Ptr QGraphicsPolygonItemConst)
  deriving (HoppyP.Show)

instance HoppyP.Eq QGraphicsPolygonItemConst where
  x == y = HoppyFHR.toPtr x == HoppyFHR.toPtr y

instance HoppyP.Ord QGraphicsPolygonItemConst where
  compare x y = HoppyP.compare (HoppyFHR.toPtr x) (HoppyFHR.toPtr y)

castQGraphicsPolygonItemToConst :: QGraphicsPolygonItem -> QGraphicsPolygonItemConst
castQGraphicsPolygonItemToConst (QGraphicsPolygonItem ptr') = QGraphicsPolygonItemConst $ HoppyF.castPtr ptr'
castQGraphicsPolygonItemToConst (QGraphicsPolygonItemGc fptr' ptr') = QGraphicsPolygonItemConstGc fptr' $ HoppyF.castPtr ptr'

instance HoppyFHR.CppPtr QGraphicsPolygonItemConst where
  nullptr = QGraphicsPolygonItemConst HoppyF.nullPtr
  
  withCppPtr (QGraphicsPolygonItemConst ptr') f' = f' ptr'
  withCppPtr (QGraphicsPolygonItemConstGc fptr' ptr') f' = HoppyF.withForeignPtr fptr' $ \_ -> f' ptr'
  
  toPtr (QGraphicsPolygonItemConst ptr') = ptr'
  toPtr (QGraphicsPolygonItemConstGc _ ptr') = ptr'
  
  touchCppPtr (QGraphicsPolygonItemConst _) = HoppyP.return ()
  touchCppPtr (QGraphicsPolygonItemConstGc fptr' _) = HoppyF.touchForeignPtr fptr'

instance HoppyFHR.Deletable QGraphicsPolygonItemConst where
  delete (QGraphicsPolygonItemConst ptr') = delete'QGraphicsPolygonItem ptr'
  delete (QGraphicsPolygonItemConstGc _ _) = HoppyP.fail $ HoppyP.concat ["Deletable.delete: Asked to delete a GC-managed ", "QGraphicsPolygonItemConst", " object."]
  
  toGc this'@(QGraphicsPolygonItemConst ptr') = if ptr' == HoppyF.nullPtr then HoppyP.return this' else HoppyP.fmap (HoppyP.flip QGraphicsPolygonItemConstGc ptr') $ HoppyF.newForeignPtr (HoppyF.castFunPtr deletePtr'QGraphicsPolygonItem :: HoppyF.FunPtr (HoppyF.Ptr () -> HoppyP.IO ())) (HoppyF.castPtr ptr' :: HoppyF.Ptr ())
  toGc this'@(QGraphicsPolygonItemConstGc {}) = HoppyP.return this'

instance QGraphicsPolygonItemConstPtr QGraphicsPolygonItemConst where
  toQGraphicsPolygonItemConst = HoppyP.id

instance M164.QAbstractGraphicsShapeItemConstPtr QGraphicsPolygonItemConst where
  toQAbstractGraphicsShapeItemConst (QGraphicsPolygonItemConst ptr') = M164.QAbstractGraphicsShapeItemConst $ castQGraphicsPolygonItemToQAbstractGraphicsShapeItem ptr'
  toQAbstractGraphicsShapeItemConst (QGraphicsPolygonItemConstGc fptr' ptr') = M164.QAbstractGraphicsShapeItemConstGc fptr' $ castQGraphicsPolygonItemToQAbstractGraphicsShapeItem ptr'

instance M202.QGraphicsItemConstPtr QGraphicsPolygonItemConst where
  toQGraphicsItemConst (QGraphicsPolygonItemConst ptr') = M202.QGraphicsItemConst $ castQGraphicsPolygonItemToQGraphicsItem ptr'
  toQGraphicsItemConst (QGraphicsPolygonItemConstGc fptr' ptr') = M202.QGraphicsItemConstGc fptr' $ castQGraphicsPolygonItemToQGraphicsItem ptr'

data QGraphicsPolygonItem =
    QGraphicsPolygonItem (HoppyF.Ptr QGraphicsPolygonItem)
  | QGraphicsPolygonItemGc (HoppyF.ForeignPtr ()) (HoppyF.Ptr QGraphicsPolygonItem)
  deriving (HoppyP.Show)

instance HoppyP.Eq QGraphicsPolygonItem where
  x == y = HoppyFHR.toPtr x == HoppyFHR.toPtr y

instance HoppyP.Ord QGraphicsPolygonItem where
  compare x y = HoppyP.compare (HoppyFHR.toPtr x) (HoppyFHR.toPtr y)

castQGraphicsPolygonItemToNonconst :: QGraphicsPolygonItemConst -> QGraphicsPolygonItem
castQGraphicsPolygonItemToNonconst (QGraphicsPolygonItemConst ptr') = QGraphicsPolygonItem $ HoppyF.castPtr ptr'
castQGraphicsPolygonItemToNonconst (QGraphicsPolygonItemConstGc fptr' ptr') = QGraphicsPolygonItemGc fptr' $ HoppyF.castPtr ptr'

instance HoppyFHR.CppPtr QGraphicsPolygonItem where
  nullptr = QGraphicsPolygonItem HoppyF.nullPtr
  
  withCppPtr (QGraphicsPolygonItem ptr') f' = f' ptr'
  withCppPtr (QGraphicsPolygonItemGc fptr' ptr') f' = HoppyF.withForeignPtr fptr' $ \_ -> f' ptr'
  
  toPtr (QGraphicsPolygonItem ptr') = ptr'
  toPtr (QGraphicsPolygonItemGc _ ptr') = ptr'
  
  touchCppPtr (QGraphicsPolygonItem _) = HoppyP.return ()
  touchCppPtr (QGraphicsPolygonItemGc fptr' _) = HoppyF.touchForeignPtr fptr'

instance HoppyFHR.Deletable QGraphicsPolygonItem where
  delete (QGraphicsPolygonItem ptr') = delete'QGraphicsPolygonItem $ (HoppyF.castPtr ptr' :: HoppyF.Ptr QGraphicsPolygonItemConst)
  delete (QGraphicsPolygonItemGc _ _) = HoppyP.fail $ HoppyP.concat ["Deletable.delete: Asked to delete a GC-managed ", "QGraphicsPolygonItem", " object."]
  
  toGc this'@(QGraphicsPolygonItem ptr') = if ptr' == HoppyF.nullPtr then HoppyP.return this' else HoppyP.fmap (HoppyP.flip QGraphicsPolygonItemGc ptr') $ HoppyF.newForeignPtr (HoppyF.castFunPtr deletePtr'QGraphicsPolygonItem :: HoppyF.FunPtr (HoppyF.Ptr () -> HoppyP.IO ())) (HoppyF.castPtr ptr' :: HoppyF.Ptr ())
  toGc this'@(QGraphicsPolygonItemGc {}) = HoppyP.return this'

instance QGraphicsPolygonItemConstPtr QGraphicsPolygonItem where
  toQGraphicsPolygonItemConst (QGraphicsPolygonItem ptr') = QGraphicsPolygonItemConst $ (HoppyF.castPtr :: HoppyF.Ptr QGraphicsPolygonItem -> HoppyF.Ptr QGraphicsPolygonItemConst) ptr'
  toQGraphicsPolygonItemConst (QGraphicsPolygonItemGc fptr' ptr') = QGraphicsPolygonItemConstGc fptr' $ (HoppyF.castPtr :: HoppyF.Ptr QGraphicsPolygonItem -> HoppyF.Ptr QGraphicsPolygonItemConst) ptr'

instance QGraphicsPolygonItemPtr QGraphicsPolygonItem where
  toQGraphicsPolygonItem = HoppyP.id

instance M164.QAbstractGraphicsShapeItemConstPtr QGraphicsPolygonItem where
  toQAbstractGraphicsShapeItemConst (QGraphicsPolygonItem ptr') = M164.QAbstractGraphicsShapeItemConst $ castQGraphicsPolygonItemToQAbstractGraphicsShapeItem $ (HoppyF.castPtr :: HoppyF.Ptr QGraphicsPolygonItem -> HoppyF.Ptr QGraphicsPolygonItemConst) ptr'
  toQAbstractGraphicsShapeItemConst (QGraphicsPolygonItemGc fptr' ptr') = M164.QAbstractGraphicsShapeItemConstGc fptr' $ castQGraphicsPolygonItemToQAbstractGraphicsShapeItem $ (HoppyF.castPtr :: HoppyF.Ptr QGraphicsPolygonItem -> HoppyF.Ptr QGraphicsPolygonItemConst) ptr'

instance M164.QAbstractGraphicsShapeItemPtr QGraphicsPolygonItem where
  toQAbstractGraphicsShapeItem (QGraphicsPolygonItem ptr') = M164.QAbstractGraphicsShapeItem $ (HoppyF.castPtr :: HoppyF.Ptr M164.QAbstractGraphicsShapeItemConst -> HoppyF.Ptr M164.QAbstractGraphicsShapeItem) $ castQGraphicsPolygonItemToQAbstractGraphicsShapeItem $ (HoppyF.castPtr :: HoppyF.Ptr QGraphicsPolygonItem -> HoppyF.Ptr QGraphicsPolygonItemConst) ptr'
  toQAbstractGraphicsShapeItem (QGraphicsPolygonItemGc fptr' ptr') = M164.QAbstractGraphicsShapeItemGc fptr' $ (HoppyF.castPtr :: HoppyF.Ptr M164.QAbstractGraphicsShapeItemConst -> HoppyF.Ptr M164.QAbstractGraphicsShapeItem) $ castQGraphicsPolygonItemToQAbstractGraphicsShapeItem $ (HoppyF.castPtr :: HoppyF.Ptr QGraphicsPolygonItem -> HoppyF.Ptr QGraphicsPolygonItemConst) ptr'

instance M202.QGraphicsItemConstPtr QGraphicsPolygonItem where
  toQGraphicsItemConst (QGraphicsPolygonItem ptr') = M202.QGraphicsItemConst $ castQGraphicsPolygonItemToQGraphicsItem $ (HoppyF.castPtr :: HoppyF.Ptr QGraphicsPolygonItem -> HoppyF.Ptr QGraphicsPolygonItemConst) ptr'
  toQGraphicsItemConst (QGraphicsPolygonItemGc fptr' ptr') = M202.QGraphicsItemConstGc fptr' $ castQGraphicsPolygonItemToQGraphicsItem $ (HoppyF.castPtr :: HoppyF.Ptr QGraphicsPolygonItem -> HoppyF.Ptr QGraphicsPolygonItemConst) ptr'

instance M202.QGraphicsItemPtr QGraphicsPolygonItem where
  toQGraphicsItem (QGraphicsPolygonItem ptr') = M202.QGraphicsItem $ (HoppyF.castPtr :: HoppyF.Ptr M202.QGraphicsItemConst -> HoppyF.Ptr M202.QGraphicsItem) $ castQGraphicsPolygonItemToQGraphicsItem $ (HoppyF.castPtr :: HoppyF.Ptr QGraphicsPolygonItem -> HoppyF.Ptr QGraphicsPolygonItemConst) ptr'
  toQGraphicsItem (QGraphicsPolygonItemGc fptr' ptr') = M202.QGraphicsItemGc fptr' $ (HoppyF.castPtr :: HoppyF.Ptr M202.QGraphicsItemConst -> HoppyF.Ptr M202.QGraphicsItem) $ castQGraphicsPolygonItemToQGraphicsItem $ (HoppyF.castPtr :: HoppyF.Ptr QGraphicsPolygonItem -> HoppyF.Ptr QGraphicsPolygonItemConst) ptr'

new ::  HoppyP.IO QGraphicsPolygonItem
new =
  HoppyP.fmap QGraphicsPolygonItem
  (new')

class QGraphicsPolygonItemSuper a where
  downToQGraphicsPolygonItem :: a -> QGraphicsPolygonItem

instance QGraphicsPolygonItemSuper M164.QAbstractGraphicsShapeItem where
  downToQGraphicsPolygonItem = castQGraphicsPolygonItemToNonconst . cast' . M164.castQAbstractGraphicsShapeItemToConst
    where
      cast' (M164.QAbstractGraphicsShapeItemConst ptr') = QGraphicsPolygonItemConst $ castQAbstractGraphicsShapeItemToQGraphicsPolygonItem ptr'
      cast' (M164.QAbstractGraphicsShapeItemConstGc fptr' ptr') = QGraphicsPolygonItemConstGc fptr' $ castQAbstractGraphicsShapeItemToQGraphicsPolygonItem ptr'
instance QGraphicsPolygonItemSuper M202.QGraphicsItem where
  downToQGraphicsPolygonItem = castQGraphicsPolygonItemToNonconst . cast' . M202.castQGraphicsItemToConst
    where
      cast' (M202.QGraphicsItemConst ptr') = QGraphicsPolygonItemConst $ castQGraphicsItemToQGraphicsPolygonItem ptr'
      cast' (M202.QGraphicsItemConstGc fptr' ptr') = QGraphicsPolygonItemConstGc fptr' $ castQGraphicsItemToQGraphicsPolygonItem ptr'

class QGraphicsPolygonItemSuperConst a where
  downToQGraphicsPolygonItemConst :: a -> QGraphicsPolygonItemConst

instance QGraphicsPolygonItemSuperConst M164.QAbstractGraphicsShapeItemConst where
  downToQGraphicsPolygonItemConst = cast'
    where
      cast' (M164.QAbstractGraphicsShapeItemConst ptr') = QGraphicsPolygonItemConst $ castQAbstractGraphicsShapeItemToQGraphicsPolygonItem ptr'
      cast' (M164.QAbstractGraphicsShapeItemConstGc fptr' ptr') = QGraphicsPolygonItemConstGc fptr' $ castQAbstractGraphicsShapeItemToQGraphicsPolygonItem ptr'
instance QGraphicsPolygonItemSuperConst M202.QGraphicsItemConst where
  downToQGraphicsPolygonItemConst = cast'
    where
      cast' (M202.QGraphicsItemConst ptr') = QGraphicsPolygonItemConst $ castQGraphicsItemToQGraphicsPolygonItem ptr'
      cast' (M202.QGraphicsItemConstGc fptr' ptr') = QGraphicsPolygonItemConstGc fptr' $ castQGraphicsItemToQGraphicsPolygonItem ptr'

instance HoppyFHR.Assignable (HoppyF.Ptr (HoppyF.Ptr QGraphicsPolygonItem)) QGraphicsPolygonItem where
  assign ptr' value' = HoppyF.poke ptr' $ HoppyFHR.toPtr value'

instance HoppyFHR.Decodable (HoppyF.Ptr (HoppyF.Ptr QGraphicsPolygonItem)) QGraphicsPolygonItem where
  decode = HoppyP.fmap QGraphicsPolygonItem . HoppyF.peek