module Graphics.X11.Xlib.Color(
lookupColor,
allocNamedColor,
allocColor,
parseColor,
freeColors,
storeColor,
queryColor,
queryColors,
installColormap,
uninstallColormap,
copyColormapAndFree,
createColormap,
freeColormap,
) where
import Graphics.X11.Types
import Graphics.X11.Xlib.Types
import Foreign
import Foreign.C
lookupColor :: Display -> Colormap -> String -> IO (Color, Color)
lookupColor display colormap color_name =
withCString color_name $ \c_color_name ->
alloca $ \ exact_def_return ->
alloca $ \ screen_def_return -> do
throwIfZero "lookupColor" $
xLookupColor display colormap c_color_name
exact_def_return screen_def_return
exact_def <- peek exact_def_return
screen_def <- peek screen_def_return
return (exact_def, screen_def)
foreign import ccall unsafe "HsXlib.h XLookupColor"
xLookupColor :: Display -> Colormap -> CString ->
Ptr Color -> Ptr Color -> IO Status
allocNamedColor :: Display -> Colormap -> String -> IO (Color, Color)
allocNamedColor display colormap color_name =
withCString color_name $ \c_color_name ->
alloca $ \ exact_def_return ->
alloca $ \ screen_def_return -> do
throwIfZero "allocNamedColor" $
xAllocNamedColor display colormap c_color_name
exact_def_return screen_def_return
exact_def <- peek exact_def_return
screen_def <- peek screen_def_return
return (exact_def, screen_def)
foreign import ccall unsafe "HsXlib.h XAllocNamedColor"
xAllocNamedColor :: Display -> Colormap -> CString ->
Ptr Color -> Ptr Color -> IO Status
allocColor :: Display -> Colormap -> Color -> IO Color
allocColor display colormap color =
with color $ \ color_ptr -> do
throwIfZero "allocColor" $
xAllocColor display colormap color_ptr
peek color_ptr
foreign import ccall unsafe "HsXlib.h XAllocColor"
xAllocColor :: Display -> Colormap -> Ptr Color -> IO Status
parseColor :: Display -> Colormap -> String -> IO Color
parseColor display colormap color_spec =
withCString color_spec $ \ spec ->
alloca $ \ exact_def_return -> do
throwIfZero "parseColor" $
xParseColor display colormap spec exact_def_return
peek exact_def_return
foreign import ccall unsafe "HsXlib.h XParseColor"
xParseColor :: Display -> Colormap -> CString -> Ptr Color -> IO Status
freeColors :: Display -> Colormap -> [Pixel] -> Pixel -> IO ()
freeColors display colormap pixels planes =
withArray pixels $ \ pixel_array ->
xFreeColors display colormap pixel_array (fromIntegral (length pixels)) planes
foreign import ccall unsafe "HsXlib.h XFreeColors"
xFreeColors :: Display -> Colormap -> Ptr Pixel -> CInt -> Pixel -> IO ()
storeColor :: Display -> Colormap -> Color -> IO ()
storeColor display colormap color =
with color $ \ color_ptr ->
xStoreColor display colormap color_ptr
foreign import ccall unsafe "HsXlib.h XStoreColor"
xStoreColor :: Display -> Colormap -> Ptr Color -> IO ()
queryColor :: Display -> Colormap -> Color -> IO Color
queryColor display colormap color =
with color $ \ color_ptr -> do
xQueryColor display colormap color_ptr
peek color_ptr
foreign import ccall unsafe "HsXlib.h XQueryColor"
xQueryColor :: Display -> Colormap -> Ptr Color -> IO ()
queryColors :: Display -> Colormap -> [Color] -> IO [Color]
queryColors display colormap colors =
withArrayLen colors $ \ ncolors color_array -> do
xQueryColors display colormap color_array (fromIntegral ncolors)
peekArray ncolors color_array
foreign import ccall unsafe "HsXlib.h XQueryColors"
xQueryColors :: Display -> Colormap -> Ptr Color -> CInt -> IO ()
foreign import ccall unsafe "HsXlib.h XInstallColormap"
installColormap :: Display -> Colormap -> IO ()
foreign import ccall unsafe "HsXlib.h XUninstallColormap"
uninstallColormap :: Display -> Colormap -> IO ()
foreign import ccall unsafe "HsXlib.h XCopyColormapAndFree"
copyColormapAndFree :: Display -> Colormap -> IO Colormap
foreign import ccall unsafe "HsXlib.h XCreateColormap"
createColormap :: Display -> Window -> Visual -> ColormapAlloc -> IO Colormap
foreign import ccall unsafe "HsXlib.h XFreeColormap"
freeColormap :: Display -> Colormap -> IO ()