#if __GLASGOW_HASKELL__ >= 709
{-# LANGUAGE Safe #-}
#else
{-# LANGUAGE Trustworthy #-}
#endif
-----------------------------------------------------------------------------
-- |
-- Module      :  Graphics.Win32.Icon
-- 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.Icon where

import Foreign (Ptr)
import Graphics.Win32.GDI.Types
import System.Win32.Types

#include "windows_cconv.h"

----------------------------------------------------------------
-- Icons
----------------------------------------------------------------

createIcon :: HINSTANCE -> Int -> Int -> BYTE -> BYTE -> Ptr BYTE -> Ptr BYTE -> IO HICON
createIcon :: HINSTANCE
-> Int
-> Int
-> BYTE
-> BYTE
-> Ptr BYTE
-> Ptr BYTE
-> IO HINSTANCE
createIcon HINSTANCE
instance_ Int
width Int
height BYTE
planes BYTE
bitsPixel Ptr BYTE
andBits Ptr BYTE
xorBits =
    String -> IO HINSTANCE -> IO HINSTANCE
forall a. String -> IO (Ptr a) -> IO (Ptr a)
failIfNull String
"CreateIcon" (IO HINSTANCE -> IO HINSTANCE) -> IO HINSTANCE -> IO HINSTANCE
forall a b. (a -> b) -> a -> b
$ HINSTANCE
-> Int
-> Int
-> BYTE
-> BYTE
-> Ptr BYTE
-> Ptr BYTE
-> IO HINSTANCE
c_CreateIcon HINSTANCE
instance_ Int
width Int
height BYTE
planes BYTE
bitsPixel Ptr BYTE
andBits Ptr BYTE
xorBits
foreign import WINDOWS_CCONV unsafe "windows.h CreateIcon"
    c_CreateIcon :: HINSTANCE -> Int -> Int -> BYTE -> BYTE -> Ptr BYTE -> Ptr BYTE -> IO HICON

copyIcon :: HICON -> IO HICON
copyIcon :: HINSTANCE -> IO HINSTANCE
copyIcon HINSTANCE
icon =
  String -> IO HINSTANCE -> IO HINSTANCE
forall a. String -> IO (Ptr a) -> IO (Ptr a)
failIfNull String
"CopyIcon" (IO HINSTANCE -> IO HINSTANCE) -> IO HINSTANCE -> IO HINSTANCE
forall a b. (a -> b) -> a -> b
$ HINSTANCE -> IO HINSTANCE
c_CopyIcon HINSTANCE
icon
foreign import WINDOWS_CCONV unsafe "windows.h CopyIcon"
  c_CopyIcon :: HICON -> IO HICON

drawIcon :: HDC -> Int -> Int -> HICON -> IO ()
drawIcon :: HINSTANCE -> Int -> Int -> HINSTANCE -> IO ()
drawIcon HINSTANCE
dc Int
x Int
y HINSTANCE
icon =
  String -> IO Bool -> IO ()
failIfFalse_ String
"DrawIcon" (IO Bool -> IO ()) -> IO Bool -> IO ()
forall a b. (a -> b) -> a -> b
$ HINSTANCE -> Int -> Int -> HINSTANCE -> IO Bool
c_DrawIcon HINSTANCE
dc Int
x Int
y HINSTANCE
icon
foreign import WINDOWS_CCONV unsafe "windows.h DrawIcon"
  c_DrawIcon :: HDC -> Int -> Int -> HICON -> IO Bool

destroyIcon :: HICON -> IO ()
destroyIcon :: HINSTANCE -> IO ()
destroyIcon HINSTANCE
icon =
  String -> IO Bool -> IO ()
failIfFalse_ String
"DestroyIcon" (IO Bool -> IO ()) -> IO Bool -> IO ()
forall a b. (a -> b) -> a -> b
$ HINSTANCE -> IO Bool
c_DestroyIcon HINSTANCE
icon
foreign import WINDOWS_CCONV unsafe "windows.h DestroyIcon"
  c_DestroyIcon :: HICON -> IO Bool

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