{-# 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.Gui.QOpenGLWindow (
  castQOpenGLWindowToQPaintDeviceWindow,
  castQPaintDeviceWindowToQOpenGLWindow,
  castQOpenGLWindowToQWindow,
  castQWindowToQOpenGLWindow,
  castQOpenGLWindowToQObject,
  castQObjectToQOpenGLWindow,
  castQOpenGLWindowToQSurface,
  castQSurfaceToQOpenGLWindow,
  castQOpenGLWindowToQPaintDevice,
  castQPaintDeviceToQOpenGLWindow,
  QOpenGLWindowValue (..),
  QOpenGLWindowConstPtr (..),
  defaultFramebufferObject,
  isValid,
  updateBehavior,
  QOpenGLWindowPtr (..),
  doneCurrent,
  grabFramebuffer,
  makeCurrent,
  QOpenGLWindowConst (..),
  castQOpenGLWindowToConst,
  QOpenGLWindow (..),
  castQOpenGLWindowToNonconst,
  new,
  newWithUpdateBehavior,
  newWithUpdateBehaviorAndParent,
  QOpenGLWindowSuper (..),
  QOpenGLWindowSuperConst (..),
  QOpenGLWindowUpdateBehavior (..),
  ) where

import qualified Data.Word as HoppyDW
import qualified Foreign as HoppyF
import qualified Foreign.C as HoppyFC
import qualified Foreign.Hoppy.Runtime as HoppyFHR
import qualified Graphics.UI.Qtah.Generated.Core.QObject as M30
import qualified Graphics.UI.Qtah.Generated.Gui.QImage as M108
import qualified Graphics.UI.Qtah.Generated.Gui.QPaintDevice as M120
import qualified Graphics.UI.Qtah.Generated.Gui.QPaintDeviceWindow as M122
import qualified Graphics.UI.Qtah.Generated.Gui.QSurface as M142
import qualified Graphics.UI.Qtah.Generated.Gui.QWindow as M150
import Prelude (($), (++), (.), (/=), (=<<), (==))
import qualified Prelude as HoppyP

foreign import ccall "genpop__QOpenGLWindow_new" new' ::  HoppyP.IO (HoppyF.Ptr QOpenGLWindow)
foreign import ccall "genpop__QOpenGLWindow_newWithUpdateBehavior" newWithUpdateBehavior' ::  HoppyFC.CInt -> HoppyP.IO (HoppyF.Ptr QOpenGLWindow)
foreign import ccall "genpop__QOpenGLWindow_newWithUpdateBehaviorAndParent" newWithUpdateBehaviorAndParent' ::  HoppyFC.CInt -> HoppyF.Ptr M150.QWindow -> HoppyP.IO (HoppyF.Ptr QOpenGLWindow)
foreign import ccall "genpop__QOpenGLWindow_defaultFramebufferObject" defaultFramebufferObject' ::  HoppyF.Ptr QOpenGLWindowConst -> HoppyP.IO HoppyDW.Word32
foreign import ccall "genpop__QOpenGLWindow_doneCurrent" doneCurrent' ::  HoppyF.Ptr QOpenGLWindow -> HoppyP.IO ()
foreign import ccall "genpop__QOpenGLWindow_grabFramebuffer" grabFramebuffer' ::  HoppyF.Ptr QOpenGLWindow -> HoppyP.IO (HoppyF.Ptr M108.QImageConst)
foreign import ccall "genpop__QOpenGLWindow_isValid" isValid' ::  HoppyF.Ptr QOpenGLWindowConst -> HoppyP.IO HoppyFHR.CBool
foreign import ccall "genpop__QOpenGLWindow_makeCurrent" makeCurrent' ::  HoppyF.Ptr QOpenGLWindow -> HoppyP.IO ()
foreign import ccall "genpop__QOpenGLWindow_updateBehavior" updateBehavior' ::  HoppyF.Ptr QOpenGLWindowConst -> HoppyP.IO HoppyFC.CInt
foreign import ccall "gencast__QOpenGLWindow__QPaintDeviceWindow" castQOpenGLWindowToQPaintDeviceWindow :: HoppyF.Ptr QOpenGLWindowConst -> HoppyF.Ptr M122.QPaintDeviceWindowConst
foreign import ccall "gencast__QPaintDeviceWindow__QOpenGLWindow" castQPaintDeviceWindowToQOpenGLWindow :: HoppyF.Ptr M122.QPaintDeviceWindowConst -> HoppyF.Ptr QOpenGLWindowConst
foreign import ccall "gencast__QOpenGLWindow__QWindow" castQOpenGLWindowToQWindow :: HoppyF.Ptr QOpenGLWindowConst -> HoppyF.Ptr M150.QWindowConst
foreign import ccall "gencast__QWindow__QOpenGLWindow" castQWindowToQOpenGLWindow :: HoppyF.Ptr M150.QWindowConst -> HoppyF.Ptr QOpenGLWindowConst
foreign import ccall "gencast__QOpenGLWindow__QObject" castQOpenGLWindowToQObject :: HoppyF.Ptr QOpenGLWindowConst -> HoppyF.Ptr M30.QObjectConst
foreign import ccall "gencast__QObject__QOpenGLWindow" castQObjectToQOpenGLWindow :: HoppyF.Ptr M30.QObjectConst -> HoppyF.Ptr QOpenGLWindowConst
foreign import ccall "gencast__QOpenGLWindow__QSurface" castQOpenGLWindowToQSurface :: HoppyF.Ptr QOpenGLWindowConst -> HoppyF.Ptr M142.QSurfaceConst
foreign import ccall "gencast__QSurface__QOpenGLWindow" castQSurfaceToQOpenGLWindow :: HoppyF.Ptr M142.QSurfaceConst -> HoppyF.Ptr QOpenGLWindowConst
foreign import ccall "gencast__QOpenGLWindow__QPaintDevice" castQOpenGLWindowToQPaintDevice :: HoppyF.Ptr QOpenGLWindowConst -> HoppyF.Ptr M120.QPaintDeviceConst
foreign import ccall "gencast__QPaintDevice__QOpenGLWindow" castQPaintDeviceToQOpenGLWindow :: HoppyF.Ptr M120.QPaintDeviceConst -> HoppyF.Ptr QOpenGLWindowConst
foreign import ccall "gendel__QOpenGLWindow" delete'QOpenGLWindow :: HoppyF.Ptr QOpenGLWindowConst -> HoppyP.IO ()
foreign import ccall "&gendel__QOpenGLWindow" deletePtr'QOpenGLWindow :: HoppyF.FunPtr (HoppyF.Ptr QOpenGLWindowConst -> HoppyP.IO ())

class QOpenGLWindowValue a where
  withQOpenGLWindowPtr :: a -> (QOpenGLWindowConst -> HoppyP.IO b) -> HoppyP.IO b

#if MIN_VERSION_base(4,8,0)
instance {-# OVERLAPPABLE #-} QOpenGLWindowConstPtr a => QOpenGLWindowValue a where
#else
instance QOpenGLWindowConstPtr a => QOpenGLWindowValue a where
#endif
  withQOpenGLWindowPtr = HoppyP.flip ($) . toQOpenGLWindowConst

class (M122.QPaintDeviceWindowConstPtr this) => QOpenGLWindowConstPtr this where
  toQOpenGLWindowConst :: this -> QOpenGLWindowConst

defaultFramebufferObject :: (QOpenGLWindowValue arg'1) => arg'1 -> HoppyP.IO HoppyDW.Word32
defaultFramebufferObject arg'1 =
  withQOpenGLWindowPtr arg'1 $ HoppyP.flip HoppyFHR.withCppPtr $ \arg'1' ->
  (defaultFramebufferObject' arg'1')

isValid :: (QOpenGLWindowValue arg'1) => arg'1 -> HoppyP.IO HoppyP.Bool
isValid arg'1 =
  withQOpenGLWindowPtr arg'1 $ HoppyP.flip HoppyFHR.withCppPtr $ \arg'1' ->
  HoppyP.fmap (/= 0)
  (isValid' arg'1')

updateBehavior :: (QOpenGLWindowValue arg'1) => arg'1 -> HoppyP.IO QOpenGLWindowUpdateBehavior
updateBehavior arg'1 =
  withQOpenGLWindowPtr arg'1 $ HoppyP.flip HoppyFHR.withCppPtr $ \arg'1' ->
  HoppyP.fmap (HoppyP.toEnum . HoppyFHR.coerceIntegral)
  (updateBehavior' arg'1')

class (QOpenGLWindowConstPtr this, M122.QPaintDeviceWindowPtr this) => QOpenGLWindowPtr this where
  toQOpenGLWindow :: this -> QOpenGLWindow

doneCurrent :: (QOpenGLWindowPtr arg'1) => arg'1 -> HoppyP.IO ()
doneCurrent arg'1 =
  HoppyFHR.withCppPtr (toQOpenGLWindow arg'1) $ \arg'1' ->
  (doneCurrent' arg'1')

grabFramebuffer :: (QOpenGLWindowPtr arg'1) => arg'1 -> HoppyP.IO M108.QImage
grabFramebuffer arg'1 =
  HoppyFHR.withCppPtr (toQOpenGLWindow arg'1) $ \arg'1' ->
  (HoppyFHR.decodeAndDelete . M108.QImageConst) =<<
  (grabFramebuffer' arg'1')

makeCurrent :: (QOpenGLWindowPtr arg'1) => arg'1 -> HoppyP.IO ()
makeCurrent arg'1 =
  HoppyFHR.withCppPtr (toQOpenGLWindow arg'1) $ \arg'1' ->
  (makeCurrent' arg'1')

data QOpenGLWindowConst =
    QOpenGLWindowConst (HoppyF.Ptr QOpenGLWindowConst)
  | QOpenGLWindowConstGc (HoppyF.ForeignPtr ()) (HoppyF.Ptr QOpenGLWindowConst)
  deriving (HoppyP.Show)

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

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

castQOpenGLWindowToConst :: QOpenGLWindow -> QOpenGLWindowConst
castQOpenGLWindowToConst (QOpenGLWindow ptr') = QOpenGLWindowConst $ HoppyF.castPtr ptr'
castQOpenGLWindowToConst (QOpenGLWindowGc fptr' ptr') = QOpenGLWindowConstGc fptr' $ HoppyF.castPtr ptr'

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

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

instance QOpenGLWindowConstPtr QOpenGLWindowConst where
  toQOpenGLWindowConst = HoppyP.id

instance M122.QPaintDeviceWindowConstPtr QOpenGLWindowConst where
  toQPaintDeviceWindowConst (QOpenGLWindowConst ptr') = M122.QPaintDeviceWindowConst $ castQOpenGLWindowToQPaintDeviceWindow ptr'
  toQPaintDeviceWindowConst (QOpenGLWindowConstGc fptr' ptr') = M122.QPaintDeviceWindowConstGc fptr' $ castQOpenGLWindowToQPaintDeviceWindow ptr'

instance M150.QWindowConstPtr QOpenGLWindowConst where
  toQWindowConst (QOpenGLWindowConst ptr') = M150.QWindowConst $ castQOpenGLWindowToQWindow ptr'
  toQWindowConst (QOpenGLWindowConstGc fptr' ptr') = M150.QWindowConstGc fptr' $ castQOpenGLWindowToQWindow ptr'

instance M30.QObjectConstPtr QOpenGLWindowConst where
  toQObjectConst (QOpenGLWindowConst ptr') = M30.QObjectConst $ castQOpenGLWindowToQObject ptr'
  toQObjectConst (QOpenGLWindowConstGc fptr' ptr') = M30.QObjectConstGc fptr' $ castQOpenGLWindowToQObject ptr'

instance M142.QSurfaceConstPtr QOpenGLWindowConst where
  toQSurfaceConst (QOpenGLWindowConst ptr') = M142.QSurfaceConst $ castQOpenGLWindowToQSurface ptr'
  toQSurfaceConst (QOpenGLWindowConstGc fptr' ptr') = M142.QSurfaceConstGc fptr' $ castQOpenGLWindowToQSurface ptr'

instance M120.QPaintDeviceConstPtr QOpenGLWindowConst where
  toQPaintDeviceConst (QOpenGLWindowConst ptr') = M120.QPaintDeviceConst $ castQOpenGLWindowToQPaintDevice ptr'
  toQPaintDeviceConst (QOpenGLWindowConstGc fptr' ptr') = M120.QPaintDeviceConstGc fptr' $ castQOpenGLWindowToQPaintDevice ptr'

data QOpenGLWindow =
    QOpenGLWindow (HoppyF.Ptr QOpenGLWindow)
  | QOpenGLWindowGc (HoppyF.ForeignPtr ()) (HoppyF.Ptr QOpenGLWindow)
  deriving (HoppyP.Show)

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

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

castQOpenGLWindowToNonconst :: QOpenGLWindowConst -> QOpenGLWindow
castQOpenGLWindowToNonconst (QOpenGLWindowConst ptr') = QOpenGLWindow $ HoppyF.castPtr ptr'
castQOpenGLWindowToNonconst (QOpenGLWindowConstGc fptr' ptr') = QOpenGLWindowGc fptr' $ HoppyF.castPtr ptr'

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

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

instance QOpenGLWindowConstPtr QOpenGLWindow where
  toQOpenGLWindowConst (QOpenGLWindow ptr') = QOpenGLWindowConst $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'
  toQOpenGLWindowConst (QOpenGLWindowGc fptr' ptr') = QOpenGLWindowConstGc fptr' $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'

instance QOpenGLWindowPtr QOpenGLWindow where
  toQOpenGLWindow = HoppyP.id

instance M122.QPaintDeviceWindowConstPtr QOpenGLWindow where
  toQPaintDeviceWindowConst (QOpenGLWindow ptr') = M122.QPaintDeviceWindowConst $ castQOpenGLWindowToQPaintDeviceWindow $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'
  toQPaintDeviceWindowConst (QOpenGLWindowGc fptr' ptr') = M122.QPaintDeviceWindowConstGc fptr' $ castQOpenGLWindowToQPaintDeviceWindow $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'

instance M122.QPaintDeviceWindowPtr QOpenGLWindow where
  toQPaintDeviceWindow (QOpenGLWindow ptr') = M122.QPaintDeviceWindow $ (HoppyF.castPtr :: HoppyF.Ptr M122.QPaintDeviceWindowConst -> HoppyF.Ptr M122.QPaintDeviceWindow) $ castQOpenGLWindowToQPaintDeviceWindow $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'
  toQPaintDeviceWindow (QOpenGLWindowGc fptr' ptr') = M122.QPaintDeviceWindowGc fptr' $ (HoppyF.castPtr :: HoppyF.Ptr M122.QPaintDeviceWindowConst -> HoppyF.Ptr M122.QPaintDeviceWindow) $ castQOpenGLWindowToQPaintDeviceWindow $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'

instance M150.QWindowConstPtr QOpenGLWindow where
  toQWindowConst (QOpenGLWindow ptr') = M150.QWindowConst $ castQOpenGLWindowToQWindow $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'
  toQWindowConst (QOpenGLWindowGc fptr' ptr') = M150.QWindowConstGc fptr' $ castQOpenGLWindowToQWindow $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'

instance M150.QWindowPtr QOpenGLWindow where
  toQWindow (QOpenGLWindow ptr') = M150.QWindow $ (HoppyF.castPtr :: HoppyF.Ptr M150.QWindowConst -> HoppyF.Ptr M150.QWindow) $ castQOpenGLWindowToQWindow $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'
  toQWindow (QOpenGLWindowGc fptr' ptr') = M150.QWindowGc fptr' $ (HoppyF.castPtr :: HoppyF.Ptr M150.QWindowConst -> HoppyF.Ptr M150.QWindow) $ castQOpenGLWindowToQWindow $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'

instance M30.QObjectConstPtr QOpenGLWindow where
  toQObjectConst (QOpenGLWindow ptr') = M30.QObjectConst $ castQOpenGLWindowToQObject $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'
  toQObjectConst (QOpenGLWindowGc fptr' ptr') = M30.QObjectConstGc fptr' $ castQOpenGLWindowToQObject $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'

instance M30.QObjectPtr QOpenGLWindow where
  toQObject (QOpenGLWindow ptr') = M30.QObject $ (HoppyF.castPtr :: HoppyF.Ptr M30.QObjectConst -> HoppyF.Ptr M30.QObject) $ castQOpenGLWindowToQObject $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'
  toQObject (QOpenGLWindowGc fptr' ptr') = M30.QObjectGc fptr' $ (HoppyF.castPtr :: HoppyF.Ptr M30.QObjectConst -> HoppyF.Ptr M30.QObject) $ castQOpenGLWindowToQObject $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'

instance M142.QSurfaceConstPtr QOpenGLWindow where
  toQSurfaceConst (QOpenGLWindow ptr') = M142.QSurfaceConst $ castQOpenGLWindowToQSurface $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'
  toQSurfaceConst (QOpenGLWindowGc fptr' ptr') = M142.QSurfaceConstGc fptr' $ castQOpenGLWindowToQSurface $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'

instance M142.QSurfacePtr QOpenGLWindow where
  toQSurface (QOpenGLWindow ptr') = M142.QSurface $ (HoppyF.castPtr :: HoppyF.Ptr M142.QSurfaceConst -> HoppyF.Ptr M142.QSurface) $ castQOpenGLWindowToQSurface $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'
  toQSurface (QOpenGLWindowGc fptr' ptr') = M142.QSurfaceGc fptr' $ (HoppyF.castPtr :: HoppyF.Ptr M142.QSurfaceConst -> HoppyF.Ptr M142.QSurface) $ castQOpenGLWindowToQSurface $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'

instance M120.QPaintDeviceConstPtr QOpenGLWindow where
  toQPaintDeviceConst (QOpenGLWindow ptr') = M120.QPaintDeviceConst $ castQOpenGLWindowToQPaintDevice $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'
  toQPaintDeviceConst (QOpenGLWindowGc fptr' ptr') = M120.QPaintDeviceConstGc fptr' $ castQOpenGLWindowToQPaintDevice $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'

instance M120.QPaintDevicePtr QOpenGLWindow where
  toQPaintDevice (QOpenGLWindow ptr') = M120.QPaintDevice $ (HoppyF.castPtr :: HoppyF.Ptr M120.QPaintDeviceConst -> HoppyF.Ptr M120.QPaintDevice) $ castQOpenGLWindowToQPaintDevice $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'
  toQPaintDevice (QOpenGLWindowGc fptr' ptr') = M120.QPaintDeviceGc fptr' $ (HoppyF.castPtr :: HoppyF.Ptr M120.QPaintDeviceConst -> HoppyF.Ptr M120.QPaintDevice) $ castQOpenGLWindowToQPaintDevice $ (HoppyF.castPtr :: HoppyF.Ptr QOpenGLWindow -> HoppyF.Ptr QOpenGLWindowConst) ptr'

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

newWithUpdateBehavior ::  QOpenGLWindowUpdateBehavior -> HoppyP.IO QOpenGLWindow
newWithUpdateBehavior arg'1 =
  let arg'1' = HoppyFHR.coerceIntegral $ HoppyP.fromEnum arg'1 in
  HoppyP.fmap QOpenGLWindow
  (newWithUpdateBehavior' arg'1')

newWithUpdateBehaviorAndParent :: (M150.QWindowPtr arg'2) => QOpenGLWindowUpdateBehavior -> arg'2 -> HoppyP.IO QOpenGLWindow
newWithUpdateBehaviorAndParent arg'1 arg'2 =
  let arg'1' = HoppyFHR.coerceIntegral $ HoppyP.fromEnum arg'1 in
  HoppyFHR.withCppPtr (M150.toQWindow arg'2) $ \arg'2' ->
  HoppyP.fmap QOpenGLWindow
  (newWithUpdateBehaviorAndParent' arg'1' arg'2')

class QOpenGLWindowSuper a where
  downToQOpenGLWindow :: a -> QOpenGLWindow

instance QOpenGLWindowSuper M122.QPaintDeviceWindow where
  downToQOpenGLWindow = castQOpenGLWindowToNonconst . cast' . M122.castQPaintDeviceWindowToConst
    where
      cast' (M122.QPaintDeviceWindowConst ptr') = QOpenGLWindowConst $ castQPaintDeviceWindowToQOpenGLWindow ptr'
      cast' (M122.QPaintDeviceWindowConstGc fptr' ptr') = QOpenGLWindowConstGc fptr' $ castQPaintDeviceWindowToQOpenGLWindow ptr'
instance QOpenGLWindowSuper M150.QWindow where
  downToQOpenGLWindow = castQOpenGLWindowToNonconst . cast' . M150.castQWindowToConst
    where
      cast' (M150.QWindowConst ptr') = QOpenGLWindowConst $ castQWindowToQOpenGLWindow ptr'
      cast' (M150.QWindowConstGc fptr' ptr') = QOpenGLWindowConstGc fptr' $ castQWindowToQOpenGLWindow ptr'
instance QOpenGLWindowSuper M30.QObject where
  downToQOpenGLWindow = castQOpenGLWindowToNonconst . cast' . M30.castQObjectToConst
    where
      cast' (M30.QObjectConst ptr') = QOpenGLWindowConst $ castQObjectToQOpenGLWindow ptr'
      cast' (M30.QObjectConstGc fptr' ptr') = QOpenGLWindowConstGc fptr' $ castQObjectToQOpenGLWindow ptr'
instance QOpenGLWindowSuper M142.QSurface where
  downToQOpenGLWindow = castQOpenGLWindowToNonconst . cast' . M142.castQSurfaceToConst
    where
      cast' (M142.QSurfaceConst ptr') = QOpenGLWindowConst $ castQSurfaceToQOpenGLWindow ptr'
      cast' (M142.QSurfaceConstGc fptr' ptr') = QOpenGLWindowConstGc fptr' $ castQSurfaceToQOpenGLWindow ptr'
instance QOpenGLWindowSuper M120.QPaintDevice where
  downToQOpenGLWindow = castQOpenGLWindowToNonconst . cast' . M120.castQPaintDeviceToConst
    where
      cast' (M120.QPaintDeviceConst ptr') = QOpenGLWindowConst $ castQPaintDeviceToQOpenGLWindow ptr'
      cast' (M120.QPaintDeviceConstGc fptr' ptr') = QOpenGLWindowConstGc fptr' $ castQPaintDeviceToQOpenGLWindow ptr'

class QOpenGLWindowSuperConst a where
  downToQOpenGLWindowConst :: a -> QOpenGLWindowConst

instance QOpenGLWindowSuperConst M122.QPaintDeviceWindowConst where
  downToQOpenGLWindowConst = cast'
    where
      cast' (M122.QPaintDeviceWindowConst ptr') = QOpenGLWindowConst $ castQPaintDeviceWindowToQOpenGLWindow ptr'
      cast' (M122.QPaintDeviceWindowConstGc fptr' ptr') = QOpenGLWindowConstGc fptr' $ castQPaintDeviceWindowToQOpenGLWindow ptr'
instance QOpenGLWindowSuperConst M150.QWindowConst where
  downToQOpenGLWindowConst = cast'
    where
      cast' (M150.QWindowConst ptr') = QOpenGLWindowConst $ castQWindowToQOpenGLWindow ptr'
      cast' (M150.QWindowConstGc fptr' ptr') = QOpenGLWindowConstGc fptr' $ castQWindowToQOpenGLWindow ptr'
instance QOpenGLWindowSuperConst M30.QObjectConst where
  downToQOpenGLWindowConst = cast'
    where
      cast' (M30.QObjectConst ptr') = QOpenGLWindowConst $ castQObjectToQOpenGLWindow ptr'
      cast' (M30.QObjectConstGc fptr' ptr') = QOpenGLWindowConstGc fptr' $ castQObjectToQOpenGLWindow ptr'
instance QOpenGLWindowSuperConst M142.QSurfaceConst where
  downToQOpenGLWindowConst = cast'
    where
      cast' (M142.QSurfaceConst ptr') = QOpenGLWindowConst $ castQSurfaceToQOpenGLWindow ptr'
      cast' (M142.QSurfaceConstGc fptr' ptr') = QOpenGLWindowConstGc fptr' $ castQSurfaceToQOpenGLWindow ptr'
instance QOpenGLWindowSuperConst M120.QPaintDeviceConst where
  downToQOpenGLWindowConst = cast'
    where
      cast' (M120.QPaintDeviceConst ptr') = QOpenGLWindowConst $ castQPaintDeviceToQOpenGLWindow ptr'
      cast' (M120.QPaintDeviceConstGc fptr' ptr') = QOpenGLWindowConstGc fptr' $ castQPaintDeviceToQOpenGLWindow ptr'

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

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

data QOpenGLWindowUpdateBehavior =
  NoPartialUpdate
  | PartialUpdateBlit
  | PartialUpdateBlend
  deriving (HoppyP.Bounded, HoppyP.Eq, HoppyP.Ord, HoppyP.Show)

instance HoppyP.Enum QOpenGLWindowUpdateBehavior where
  fromEnum NoPartialUpdate = 0
  fromEnum PartialUpdateBlit = 1
  fromEnum PartialUpdateBlend = 2
  
  toEnum (0) = NoPartialUpdate
  toEnum (1) = PartialUpdateBlit
  toEnum (2) = PartialUpdateBlend
  toEnum n' = HoppyP.error $ "Unknown QOpenGLWindowUpdateBehavior numeric value: " ++ HoppyP.show n'