#if __GLASGOW_HASKELL__ >= 709
{-# LANGUAGE Safe #-}
#else
{-# LANGUAGE Trustworthy #-}
#endif
-----------------------------------------------------------------------------
-- |
-- Module      :  Graphics.Win32.GDI.HDC
-- Copyright   :  (c) Alastair Reid, 1997-2003
-- License     :  BSD-style (see the file libraries/base/LICENSE)
--
-- Maintainer  :  Esa Ilari Vuokko <ei@vuokko.info>
-- Stability   :  provisional
-- Portability :  portable
--
-- A collection of FFI declarations for interfacing with Win32.
--
-----------------------------------------------------------------------------

module Graphics.Win32.GDI.HDC
        ( module Graphics.Win32.GDI.HDC
        ) where

import System.Win32.Types
import Graphics.Win32.GDI.Types

import Foreign

#include "windows_cconv.h"

{- Note [Overflow checking and fromIntegral]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Some windows APIs use the value 0x80000000 to represent failure return
codes. However, when GHC builds libraries with -XNegativeLiterals
enabled, it will fail in contexts where the type would suffer from
signed overflow - such as Int32. (minBound :: Int32 == 0x80000000)

Technically, the frontend is correct that the literal overflows in the
context it is used in. So instead, we use fromIntegral to convert the
literal from a Word32 to the necessary type. This isn't any less
efficient (fromIntegral is optimized away,) and conveys the idea we
simply want the same representational value.
-}

----------------------
-- Implement GetPixel
----------------------

getPixel :: HDC -> Int -> Int -> IO COLORREF
getPixel :: HDC -> Int -> Int -> IO Word32
getPixel HDC
dc Int
x Int
y = HDC -> Int -> Int -> IO Word32
c_GetPixel HDC
dc Int
x Int
y
foreign import WINDOWS_CCONV unsafe "windows.h GetPixel"
  c_GetPixel :: HDC -> Int -> Int -> IO COLORREF

----------------------

setArcDirection :: HDC -> ArcDirection -> IO ArcDirection
setArcDirection :: HDC -> RegionType -> IO RegionType
setArcDirection HDC
dc RegionType
dir =
  forall a. (Eq a, Num a) => String -> IO a -> IO a
failIfZero String
"SetArcDirection" forall a b. (a -> b) -> a -> b
$ HDC -> RegionType -> IO RegionType
c_SetArcDirection HDC
dc RegionType
dir
foreign import WINDOWS_CCONV unsafe "windows.h SetArcDirection"
  c_SetArcDirection :: HDC ->  ArcDirection  -> IO  ArcDirection

getArcDirection :: HDC -> IO ArcDirection
getArcDirection :: HDC -> IO RegionType
getArcDirection HDC
dc =
  forall a. (Eq a, Num a) => String -> IO a -> IO a
failIfZero String
"GetArcDirection" forall a b. (a -> b) -> a -> b
$ HDC -> IO RegionType
c_GetArcDirection HDC
dc
foreign import WINDOWS_CCONV unsafe "windows.h GetArcDirection"
  c_GetArcDirection :: HDC -> IO  ArcDirection

setPolyFillMode :: HDC -> PolyFillMode -> IO PolyFillMode
setPolyFillMode :: HDC -> RegionType -> IO RegionType
setPolyFillMode HDC
dc RegionType
mode =
  forall a. (Eq a, Num a) => String -> IO a -> IO a
failIfZero String
"SetPolyFillMode" forall a b. (a -> b) -> a -> b
$ HDC -> RegionType -> IO RegionType
c_SetPolyFillMode HDC
dc RegionType
mode
foreign import WINDOWS_CCONV unsafe "windows.h SetPolyFillMode"
  c_SetPolyFillMode :: HDC ->  PolyFillMode  -> IO  PolyFillMode

getPolyFillMode :: HDC -> IO PolyFillMode
getPolyFillMode :: HDC -> IO RegionType
getPolyFillMode HDC
dc =
  forall a. (Eq a, Num a) => String -> IO a -> IO a
failIfZero String
"GetPolyFillMode" forall a b. (a -> b) -> a -> b
$ HDC -> IO RegionType
c_GetPolyFillMode HDC
dc
foreign import WINDOWS_CCONV unsafe "windows.h GetPolyFillMode"
  c_GetPolyFillMode :: HDC -> IO  PolyFillMode

setGraphicsMode :: HDC -> GraphicsMode -> IO GraphicsMode
setGraphicsMode :: HDC -> Word32 -> IO Word32
setGraphicsMode HDC
dc Word32
mode =
  forall a. (Eq a, Num a) => String -> IO a -> IO a
failIfZero String
"SetGraphicsMode" forall a b. (a -> b) -> a -> b
$ HDC -> Word32 -> IO Word32
c_SetGraphicsMode HDC
dc Word32
mode
foreign import WINDOWS_CCONV unsafe "windows.h SetGraphicsMode"
  c_SetGraphicsMode :: HDC ->  GraphicsMode  -> IO  GraphicsMode

getGraphicsMode :: HDC -> IO GraphicsMode
getGraphicsMode :: HDC -> IO Word32
getGraphicsMode HDC
dc =
  forall a. (Eq a, Num a) => String -> IO a -> IO a
failIfZero String
"GetGraphicsMode" forall a b. (a -> b) -> a -> b
$ HDC -> IO Word32
c_GetGraphicsMode HDC
dc
foreign import WINDOWS_CCONV unsafe "windows.h GetGraphicsMode"
  c_GetGraphicsMode :: HDC -> IO  GraphicsMode

setStretchBltMode :: HDC -> StretchBltMode -> IO StretchBltMode
setStretchBltMode :: HDC -> RegionType -> IO RegionType
setStretchBltMode HDC
dc RegionType
mode =
  forall a. (Eq a, Num a) => String -> IO a -> IO a
failIfZero String
"SetStretchBltMode" forall a b. (a -> b) -> a -> b
$ HDC -> RegionType -> IO RegionType
c_SetStretchBltMode HDC
dc RegionType
mode
foreign import WINDOWS_CCONV unsafe "windows.h SetStretchBltMode"
  c_SetStretchBltMode :: HDC ->  StretchBltMode  -> IO  StretchBltMode

getStretchBltMode :: HDC -> IO StretchBltMode
getStretchBltMode :: HDC -> IO RegionType
getStretchBltMode HDC
dc =
  forall a. (Eq a, Num a) => String -> IO a -> IO a
failIfZero String
"GetStretchBltMode" forall a b. (a -> b) -> a -> b
$ HDC -> IO RegionType
c_GetStretchBltMode HDC
dc
foreign import WINDOWS_CCONV unsafe "windows.h GetStretchBltMode"
  c_GetStretchBltMode :: HDC -> IO  StretchBltMode

setBkColor :: HDC -> COLORREF -> IO COLORREF
setBkColor :: HDC -> Word32 -> IO Word32
setBkColor HDC
dc Word32
color =
  forall a. (Eq a, Num a) => String -> IO a -> IO a
failIfZero String
"SetBkColor" forall a b. (a -> b) -> a -> b
$ HDC -> Word32 -> IO Word32
c_SetBkColor HDC
dc Word32
color
foreign import WINDOWS_CCONV unsafe "windows.h SetBkColor"
  c_SetBkColor :: HDC ->  COLORREF  -> IO  COLORREF

getBkColor :: HDC -> IO COLORREF
getBkColor :: HDC -> IO Word32
getBkColor HDC
dc =
  forall a. (Eq a, Num a) => String -> IO a -> IO a
failIfZero String
"GetBkColor" forall a b. (a -> b) -> a -> b
$ HDC -> IO Word32
c_GetBkColor HDC
dc
foreign import WINDOWS_CCONV unsafe "windows.h GetBkColor"
  c_GetBkColor :: HDC -> IO  COLORREF

setTextColor :: HDC -> COLORREF -> IO COLORREF
setTextColor :: HDC -> Word32 -> IO Word32
setTextColor HDC
dc Word32
color =
  forall a. (a -> Bool) -> String -> IO a -> IO a
failIf (forall a. Eq a => a -> a -> Bool
== Word32
cLR_INVALID) String
"SetTextColor" forall a b. (a -> b) -> a -> b
$ HDC -> Word32 -> IO Word32
c_SetTextColor HDC
dc Word32
color
foreign import WINDOWS_CCONV unsafe "windows.h SetTextColor"
  c_SetTextColor :: HDC ->  COLORREF  -> IO  COLORREF

getTextColor :: HDC -> IO COLORREF
getTextColor :: HDC -> IO Word32
getTextColor HDC
dc =
  forall a. (a -> Bool) -> String -> IO a -> IO a
failIf (forall a. Eq a => a -> a -> Bool
== Word32
cLR_INVALID) String
"GetTextColor" forall a b. (a -> b) -> a -> b
$ HDC -> IO Word32
c_GetTextColor HDC
dc
foreign import WINDOWS_CCONV unsafe "windows.h GetTextColor"
  c_GetTextColor :: HDC -> IO  COLORREF

setBkMode :: HDC -> BackgroundMode -> IO BackgroundMode
setBkMode :: HDC -> RegionType -> IO RegionType
setBkMode HDC
dc RegionType
mode =
  forall a. (Eq a, Num a) => String -> IO a -> IO a
failIfZero String
"SetBkMode" forall a b. (a -> b) -> a -> b
$ HDC -> RegionType -> IO RegionType
c_SetBkMode HDC
dc RegionType
mode
foreign import WINDOWS_CCONV unsafe "windows.h SetBkMode"
  c_SetBkMode :: HDC ->  BackgroundMode  -> IO  BackgroundMode

getBkMode :: HDC -> IO BackgroundMode
getBkMode :: HDC -> IO RegionType
getBkMode HDC
dc =
  forall a. (Eq a, Num a) => String -> IO a -> IO a
failIfZero String
"GetBkMode" forall a b. (a -> b) -> a -> b
$ HDC -> IO RegionType
c_GetBkMode HDC
dc
foreign import WINDOWS_CCONV unsafe "windows.h GetBkMode"
  c_GetBkMode :: HDC -> IO  BackgroundMode

setBrushOrgEx :: HDC -> Int -> Int -> IO POINT
setBrushOrgEx :: HDC -> Int -> Int -> IO POINT
setBrushOrgEx HDC
dc Int
x Int
y =
  forall a. (Ptr POINT -> IO a) -> IO a
allocaPOINT forall a b. (a -> b) -> a -> b
$ \ Ptr POINT
pt -> do
  String -> IO Bool -> IO ()
failIfFalse_ String
"SetBrushOrgEx" forall a b. (a -> b) -> a -> b
$ HDC -> Int -> Int -> Ptr POINT -> IO Bool
c_SetBrushOrgEx HDC
dc Int
x Int
y Ptr POINT
pt
  Ptr POINT -> IO POINT
peekPOINT Ptr POINT
pt
foreign import WINDOWS_CCONV unsafe "windows.h SetBrushOrgEx"
  c_SetBrushOrgEx :: HDC -> Int -> Int -> Ptr POINT -> IO Bool

getBrushOrgEx :: HDC -> IO POINT
getBrushOrgEx :: HDC -> IO POINT
getBrushOrgEx HDC
dc =
  forall a. (Ptr POINT -> IO a) -> IO a
allocaPOINT forall a b. (a -> b) -> a -> b
$ \ Ptr POINT
pt -> do
  String -> IO Bool -> IO ()
failIfFalse_ String
"GetBrushOrgEx" forall a b. (a -> b) -> a -> b
$ HDC -> Ptr POINT -> IO Bool
c_GetBrushOrgEx HDC
dc Ptr POINT
pt
  Ptr POINT -> IO POINT
peekPOINT Ptr POINT
pt
foreign import WINDOWS_CCONV unsafe "windows.h GetBrushOrgEx"
  c_GetBrushOrgEx :: HDC -> Ptr POINT -> IO Bool

setTextAlign :: HDC -> TextAlignment -> IO TextAlignment
setTextAlign :: HDC -> Word32 -> IO Word32
setTextAlign HDC
dc Word32
align =
  forall a. (a -> Bool) -> String -> IO a -> IO a
failIf (forall a. Eq a => a -> a -> Bool
== forall a. Num a => a
gDI_ERROR) String
"SetTextAlign" forall a b. (a -> b) -> a -> b
$ HDC -> Word32 -> IO Word32
c_SetTextAlign HDC
dc Word32
align
foreign import WINDOWS_CCONV unsafe "windows.h SetTextAlign"
  c_SetTextAlign :: HDC ->  TextAlignment  -> IO  TextAlignment

getTextAlign :: HDC -> IO TextAlignment
getTextAlign :: HDC -> IO Word32
getTextAlign HDC
dc =
  forall a. (a -> Bool) -> String -> IO a -> IO a
failIf (forall a. Eq a => a -> a -> Bool
== forall a. Num a => a
gDI_ERROR) String
"GetTextAlign" forall a b. (a -> b) -> a -> b
$ HDC -> IO Word32
c_GetTextAlign HDC
dc
foreign import WINDOWS_CCONV unsafe "windows.h GetTextAlign"
  c_GetTextAlign :: HDC -> IO  TextAlignment

setTextCharacterExtra :: HDC -> Int -> IO Int
setTextCharacterExtra :: HDC -> Int -> IO Int
setTextCharacterExtra HDC
dc Int
extra =
  -- See Note [Overflow checking and fromIntegral]
  forall a. (a -> Bool) -> String -> IO a -> IO a
failIf (forall a. Eq a => a -> a -> Bool
== forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32
0x80000000 :: Word32)) String
"SetTextCharacterExtra" forall a b. (a -> b) -> a -> b
$
    HDC -> Int -> IO Int
c_SetTextCharacterExtra HDC
dc Int
extra
foreign import WINDOWS_CCONV unsafe "windows.h SetTextCharacterExtra"
  c_SetTextCharacterExtra :: HDC ->  Int  -> IO  Int

getTextCharacterExtra :: HDC -> IO Int
getTextCharacterExtra :: HDC -> IO Int
getTextCharacterExtra HDC
dc =
  -- See Note [Overflow checking and fromIntegral]
  forall a. (a -> Bool) -> String -> IO a -> IO a
failIf (forall a. Eq a => a -> a -> Bool
== forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32
0x80000000 :: Word32)) String
"GetTextCharacterExtra" forall a b. (a -> b) -> a -> b
$ HDC -> IO Int
c_GetTextCharacterExtra HDC
dc
foreign import WINDOWS_CCONV unsafe "windows.h GetTextCharacterExtra"
  c_GetTextCharacterExtra :: HDC -> IO  Int

getMiterLimit :: HDC -> IO Float
getMiterLimit :: HDC -> IO FLOAT
getMiterLimit HDC
dc =
  forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \ Ptr FLOAT
p_res -> do
  String -> IO Bool -> IO ()
failIfFalse_ String
"GetMiterLimit" forall a b. (a -> b) -> a -> b
$ HDC -> Ptr FLOAT -> IO Bool
c_GetMiterLimit HDC
dc Ptr FLOAT
p_res
  forall a. Storable a => Ptr a -> IO a
peek Ptr FLOAT
p_res
foreign import WINDOWS_CCONV unsafe "windows.h GetMiterLimit"
  c_GetMiterLimit :: HDC -> Ptr FLOAT -> IO Bool

setMiterLimit :: HDC -> Float -> IO Float
setMiterLimit :: HDC -> FLOAT -> IO FLOAT
setMiterLimit HDC
dc FLOAT
new_limit =
  forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \ Ptr FLOAT
p_old_limit -> do
  String -> IO Bool -> IO ()
failIfFalse_ String
"SetMiterLimit" forall a b. (a -> b) -> a -> b
$ HDC -> FLOAT -> Ptr FLOAT -> IO Bool
c_SetMiterLimit HDC
dc FLOAT
new_limit Ptr FLOAT
p_old_limit
  forall a. Storable a => Ptr a -> IO a
peek Ptr FLOAT
p_old_limit
foreign import WINDOWS_CCONV unsafe "windows.h SetMiterLimit"
  c_SetMiterLimit :: HDC -> FLOAT -> Ptr FLOAT -> IO Bool

----------------------------------------------------------------

saveDC :: HDC -> IO Int
saveDC :: HDC -> IO Int
saveDC HDC
dc =
  forall a. (Eq a, Num a) => String -> IO a -> IO a
failIfZero String
"SaveDC" forall a b. (a -> b) -> a -> b
$ HDC -> IO Int
c_SaveDC HDC
dc
foreign import WINDOWS_CCONV unsafe "windows.h SaveDC"
  c_SaveDC :: HDC -> IO Int

restoreDC :: HDC -> Int -> IO ()
restoreDC :: HDC -> Int -> IO ()
restoreDC HDC
dc Int
saved =
  String -> IO Bool -> IO ()
failIfFalse_ String
"RestoreDC" forall a b. (a -> b) -> a -> b
$ HDC -> Int -> IO Bool
c_RestoreDC HDC
dc Int
saved
foreign import WINDOWS_CCONV unsafe "windows.h RestoreDC"
  c_RestoreDC :: HDC -> Int -> IO Bool

----------------------------------------------------------------

getCurrentBitmap :: HDC -> IO HBITMAP
getCurrentBitmap :: HDC -> IO HDC
getCurrentBitmap HDC
dc =
  forall a. String -> IO (Ptr a) -> IO (Ptr a)
failIfNull String
"GetCurrentBitmap" forall a b. (a -> b) -> a -> b
$ HDC -> Word32 -> IO HDC
c_GetCurrentBitmap HDC
dc Word32
oBJ_BITMAP
foreign import WINDOWS_CCONV unsafe "windows.h GetCurrentObject"
  c_GetCurrentBitmap :: HDC -> UINT -> IO  HBITMAP

getCurrentBrush :: HDC -> IO HBRUSH
getCurrentBrush :: HDC -> IO HDC
getCurrentBrush HDC
dc =
  forall a. String -> IO (Ptr a) -> IO (Ptr a)
failIfNull String
"GetCurrentBrush" forall a b. (a -> b) -> a -> b
$ HDC -> Word32 -> IO HDC
c_GetCurrentBrush HDC
dc Word32
oBJ_BRUSH
foreign import WINDOWS_CCONV unsafe "windows.h GetCurrentObject"
  c_GetCurrentBrush :: HDC -> UINT -> IO   HBRUSH

getCurrentFont :: HDC -> IO HFONT
getCurrentFont :: HDC -> IO HDC
getCurrentFont HDC
dc =
  forall a. String -> IO (Ptr a) -> IO (Ptr a)
failIfNull String
"GetCurrentFont" forall a b. (a -> b) -> a -> b
$ HDC -> Word32 -> IO HDC
c_GetCurrentFont HDC
dc Word32
oBJ_FONT
foreign import WINDOWS_CCONV unsafe "windows.h GetCurrentObject"
  c_GetCurrentFont :: HDC -> UINT -> IO    HFONT

getCurrentPalette :: HDC -> IO HPALETTE
getCurrentPalette :: HDC -> IO HDC
getCurrentPalette HDC
dc =
  forall a. String -> IO (Ptr a) -> IO (Ptr a)
failIfNull String
"GetCurrentPalette" forall a b. (a -> b) -> a -> b
$ HDC -> Word32 -> IO HDC
c_GetCurrentPalette HDC
dc Word32
oBJ_PAL
foreign import WINDOWS_CCONV unsafe "windows.h GetCurrentObject"
  c_GetCurrentPalette :: HDC -> UINT -> IO     HPALETTE

getCurrentPen :: HDC -> IO HPEN
getCurrentPen :: HDC -> IO HDC
getCurrentPen HDC
dc =
  forall a. String -> IO (Ptr a) -> IO (Ptr a)
failIfNull String
"GetCurrentPen" forall a b. (a -> b) -> a -> b
$ HDC -> Word32 -> IO HDC
c_GetCurrentPen HDC
dc Word32
oBJ_PEN
foreign import WINDOWS_CCONV unsafe "windows.h GetCurrentObject"
  c_GetCurrentPen :: HDC -> UINT -> IO     HPEN

selectBitmap :: HDC -> HBITMAP -> IO HBITMAP
selectBitmap :: HDC -> HDC -> IO HDC
selectBitmap HDC
dc HDC
bitmap =
  forall a. String -> IO (Ptr a) -> IO (Ptr a)
failIfNull String
"SelectBitmap" forall a b. (a -> b) -> a -> b
$ HDC -> HDC -> IO HDC
c_SelectBitmap HDC
dc HDC
bitmap
foreign import WINDOWS_CCONV unsafe "windows.h SelectObject"
  c_SelectBitmap :: HDC ->   HBITMAP  -> IO   HBITMAP

selectBrush :: HDC -> HBRUSH -> IO HBRUSH
selectBrush :: HDC -> HDC -> IO HDC
selectBrush HDC
dc HDC
brush =
  forall a. String -> IO (Ptr a) -> IO (Ptr a)
failIfNull String
"SelectBrush" forall a b. (a -> b) -> a -> b
$ HDC -> HDC -> IO HDC
c_SelectBrush HDC
dc HDC
brush
foreign import WINDOWS_CCONV unsafe "windows.h SelectObject"
  c_SelectBrush :: HDC ->    HBRUSH  -> IO    HBRUSH

selectFont :: HDC -> HFONT -> IO HFONT
selectFont :: HDC -> HDC -> IO HDC
selectFont HDC
dc HDC
font =
  forall a. String -> IO (Ptr a) -> IO (Ptr a)
failIfNull String
"SelectFont" forall a b. (a -> b) -> a -> b
$ HDC -> HDC -> IO HDC
c_SelectFont HDC
dc HDC
font
foreign import WINDOWS_CCONV unsafe "windows.h SelectObject"
  c_SelectFont :: HDC ->     HFONT  -> IO     HFONT

selectPen :: HDC -> HPEN -> IO HPEN
selectPen :: HDC -> HDC -> IO HDC
selectPen HDC
dc HDC
pen =
  forall a. String -> IO (Ptr a) -> IO (Ptr a)
failIfNull String
"SelectPen" forall a b. (a -> b) -> a -> b
$ HDC -> HDC -> IO HDC
c_SelectPen HDC
dc HDC
pen
foreign import WINDOWS_CCONV unsafe "windows.h SelectObject"
  c_SelectPen :: HDC ->      HPEN  -> IO      HPEN

----------------------------------------------------------------
--
----------------------------------------------------------------

selectPalette :: HDC -> HPALETTE -> Bool -> IO HPALETTE
selectPalette :: HDC -> HDC -> Bool -> IO HDC
selectPalette HDC
dc HDC
palette Bool
force_bg =
  forall a. String -> IO (Ptr a) -> IO (Ptr a)
failIfNull String
"SelectPalette" forall a b. (a -> b) -> a -> b
$ HDC -> HDC -> Bool -> IO HDC
c_SelectPalette HDC
dc HDC
palette Bool
force_bg
foreign import WINDOWS_CCONV unsafe "windows.h SelectPalette"
  c_SelectPalette :: HDC -> HPALETTE -> Bool -> IO HPALETTE

selectRgn :: HDC -> HRGN -> IO RegionType
selectRgn :: HDC -> HRGN -> IO RegionType
selectRgn HDC
dc HRGN
rgn =
  forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr HRGN
rgn forall a b. (a -> b) -> a -> b
$ \ HDC
p_rgn ->
  forall a. (a -> Bool) -> String -> IO a -> IO a
failIf (forall a. Eq a => a -> a -> Bool
== forall a. Num a => a
gDI_ERROR) String
"SelectRgn" forall a b. (a -> b) -> a -> b
$ HDC -> HDC -> IO RegionType
c_SelectRgn HDC
dc HDC
p_rgn
foreign import ccall unsafe "windows.h SelectObjectInt"
  c_SelectRgn :: HDC -> PRGN -> IO RegionType
-- avoid using SelectObject() at different types by calling our own
-- wrapper.

selectClipRgn :: HDC -> Maybe HRGN -> IO RegionType
selectClipRgn :: HDC -> Maybe HRGN -> IO RegionType
selectClipRgn HDC
dc Maybe HRGN
mb_rgn =
  forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Maybe HRGN
mb_rgn forall a b. (a -> b) -> a -> b
$ \ HDC
p_rgn ->
  forall a. (Eq a, Num a) => String -> IO a -> IO a
failIfZero String
"SelectClipRgn" forall a b. (a -> b) -> a -> b
$ HDC -> HDC -> IO RegionType
c_SelectClipRgn HDC
dc HDC
p_rgn
foreign import WINDOWS_CCONV unsafe "windows.h SelectClipRgn"
  c_SelectClipRgn :: HDC -> PRGN -> IO RegionType

extSelectClipRgn :: HDC -> Maybe HRGN -> ClippingMode -> IO RegionType
extSelectClipRgn :: HDC -> Maybe HRGN -> RegionType -> IO RegionType
extSelectClipRgn HDC
dc Maybe HRGN
mb_rgn RegionType
mode =
  forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Maybe HRGN
mb_rgn forall a b. (a -> b) -> a -> b
$ \ HDC
p_rgn ->
  forall a. (Eq a, Num a) => String -> IO a -> IO a
failIfZero String
"ExtSelectClipRgn" forall a b. (a -> b) -> a -> b
$ HDC -> HDC -> RegionType -> IO RegionType
c_ExtSelectClipRgn HDC
dc HDC
p_rgn RegionType
mode
foreign import WINDOWS_CCONV unsafe "windows.h ExtSelectClipRgn"
  c_ExtSelectClipRgn :: HDC -> PRGN -> ClippingMode -> IO RegionType

selectClipPath :: HDC -> ClippingMode -> IO RegionType
selectClipPath :: HDC -> RegionType -> IO RegionType
selectClipPath HDC
dc RegionType
mode =
  forall a. (Eq a, Num a) => String -> IO a -> IO a
failIfZero String
"SelectClipPath" forall a b. (a -> b) -> a -> b
$ HDC -> RegionType -> IO RegionType
c_SelectClipPath HDC
dc RegionType
mode
foreign import WINDOWS_CCONV unsafe "windows.h SelectClipPath"
  c_SelectClipPath :: HDC -> ClippingMode -> IO RegionType

----------------------------------------------------------------
-- Misc
----------------------------------------------------------------

cancelDC :: HDC -> IO ()
cancelDC :: HDC -> IO ()
cancelDC HDC
dc =
  String -> IO Bool -> IO ()
failIfFalse_ String
"CancelDC" forall a b. (a -> b) -> a -> b
$ HDC -> IO Bool
c_CancelDC HDC
dc
foreign import WINDOWS_CCONV unsafe "windows.h CancelDC"
  c_CancelDC :: HDC -> IO Bool

createCompatibleDC :: Maybe HDC -> IO HDC
createCompatibleDC :: Maybe HDC -> IO HDC
createCompatibleDC Maybe HDC
mb_dc =
  forall a. String -> IO (Ptr a) -> IO (Ptr a)
failIfNull String
"CreateCompatibleDC" forall a b. (a -> b) -> a -> b
$ HDC -> IO HDC
c_CreateCompatibleDC (forall a. Maybe (Ptr a) -> Ptr a
maybePtr Maybe HDC
mb_dc)
foreign import WINDOWS_CCONV unsafe "windows.h CreateCompatibleDC"
  c_CreateCompatibleDC :: HDC -> IO HDC

deleteDC :: HDC -> IO ()
deleteDC :: HDC -> IO ()
deleteDC HDC
dc =
  String -> IO Bool -> IO ()
failIfFalse_ String
"DeleteDC" forall a b. (a -> b) -> a -> b
$ HDC -> IO Bool
c_DeleteDC HDC
dc
foreign import WINDOWS_CCONV unsafe "windows.h DeleteDC"
  c_DeleteDC :: HDC -> IO Bool

----------------------------------------------------------------
-- End
----------------------------------------------------------------