|
From: <kr_...@us...> - 2003-03-15 01:06:39
|
Update of /cvsroot/htoolkit/port/src/Port
In directory sc8-pr-cvs1:/tmp/cvs-serv24588/src/Port
Modified Files:
Canvas.hs ColorDialog.hs Types.hs
Added Files:
Colors.hs
Log Message:
Add comprehencive list of predefined colors. The new Colors module contains the abstract data definition for Color type and a lot of functions which represents predefined colors.
--- NEW FILE: Colors.hs ---
{-# OPTIONS -fglasgow-exts #-}
-----------------------------------------------------------------------------------------
{-| Module : Colors
Copyright : (c) Krasimir Angelov 2003
License : BSD-style
Maintainer : ka2...@ya...
Stability : provisional
Portability : portable
The module defines the abstract data type which represents colors and defines a
large set of predefined colors. The full list of predefined colors is
visible here: <colors.html>
-}
-----------------------------------------------------------------------------------------
module Graphics.UI.Port.Colors
( -- * Color type
Color
, rgbColor, colorRed, colorGreen, colorBlue
-- * Standard colors.
, aliceblue, antiquewhite, aqua, aquamarine, azure, beige
, bisque, black, blanchedalmond, blue, blueviolet, brown
, burlywood, cadetblue, chartreuse, chocolate, coral
, cornflower, cornsilk, crimson, cyan, darkblue, darkcyan
, darkgoldenrod, darkgray, darkgreen, darkkhaki
, darkmagenta, darkolivegreen, darkorange, darkorchid
, darkred, darksalmon, darkseagreen, darkslateblue
, darkslategray, darkturquoise, darkviolet, deeppink
, deepskyblue, dimgray, dodgerblue, firebrick
, floralwhite, forestgreen, fuchsia, gainsboro
, ghostwhite, gold, goldenrod, gray, green, greenyellow
, honeydew, hotpink, indianred, indigo, ivory, khaki
, lavender, lavenderblush, lawngreen, lemonchiffon
, lightblue, lightcoral, lightcyan, lightgoldenrodyellow
, lightgreen, lightgray, lightpink, lightsalmon
, lightseagreen, lightskyblue, lightslategray
, lightsteelblue, lightyellow, lime
, limegreen, linen, magenta, maroon, mediumaquamarine
, mediumblue, mediumorchid, mediumpurple, mediumseagreen
, mediumslateblue, mediumspringgreen, mediumturquoise
, mediumvioletred, midnightblue, mintcream, mistyrose
, moccasin, navajowhite, navy, oldlace, olive, olivedrab
, orange, orangered, orchid, palegoldenrod, palegreen
, paleturquoise, palevioletred, papayawhip, peachpuff
, peru, pink, plum, powderblue, purple, red, rosybrown
, royalblue, saddlebrown, salmon, sandybrown, seagreen
, seashell, sienna, silver, skyblue, slateblue, slategray
, snow, springgreen, steelblue, teal, thistle, tomato
, turquoise, violet, wheat, white, whitesmoke, yellow
, yellowgreen, dialoggray
-- * Marshalling
, CColor, fromCColor, toCColor
) where
import Foreign.C
import Data.Word
import Data.Bits
newtype Color = Color Word deriving Eq
instance Show Color where
showsPrec d c
| c == aliceblue = showString "aliceblue"
| c == antiquewhite = showString "antiquewhite"
| c == aqua = showString "aqua"
| c == aquamarine = showString "aquamarine"
| c == azure = showString "azure"
| c == beige = showString "beige"
| c == bisque = showString "bisque"
| c == black = showString "black"
| c == blanchedalmond = showString "blanchedalmond"
| c == blue = showString "blue"
| c == blueviolet = showString "blueviolet"
| c == brown = showString "brown"
| c == burlywood = showString "burlywood"
| c == cadetblue = showString "cadetblue"
| c == chartreuse = showString "chartreuse"
| c == chocolate = showString "chocolate"
| c == coral = showString "coral"
| c == cornflower = showString "cornflower"
| c == cornsilk = showString "cornsilk"
| c == crimson = showString "crimson"
| c == cyan = showString "cyan"
| c == darkblue = showString "darkblue"
| c == darkcyan = showString "darkcyan"
| c == darkgoldenrod = showString "darkgoldenrod"
| c == darkgray = showString "darkgray"
| c == darkgreen = showString "darkgreen"
| c == darkkhaki = showString "darkkhaki"
| c == darkmagenta = showString "darkmagenta"
| c == darkolivegreen = showString "darkolivegreen"
| c == darkorange = showString "darkorange"
| c == darkorchid = showString "darkorchid"
| c == darkred = showString "darkred"
| c == darksalmon = showString "darksalmon"
| c == darkseagreen = showString "darkseagreen"
| c == darkslateblue = showString "darkslateblue"
| c == darkslategray = showString "darkslategray"
| c == darkturquoise = showString "darkturquoise"
| c == darkviolet = showString "darkviolet"
| c == deeppink = showString "deeppink"
| c == deepskyblue = showString "deepskyblue"
| c == dimgray = showString "dimgray"
| c == dodgerblue = showString "dodgerblue"
| c == firebrick = showString "firebrick"
| c == floralwhite = showString "floralwhite"
| c == forestgreen = showString "forestgreen"
| c == fuchsia = showString "fuchsia"
| c == gainsboro = showString "gainsboro"
| c == ghostwhite = showString "ghostwhite"
| c == gold = showString "gold"
| c == goldenrod = showString "goldenrod"
| c == gray = showString "gray"
| c == green = showString "green"
| c == greenyellow = showString "greenyellow"
| c == honeydew = showString "honeydew"
| c == hotpink = showString "hotpink"
| c == indianred = showString "indianred"
| c == indigo = showString "indigo"
| c == ivory = showString "ivory"
| c == khaki = showString "khaki"
| c == lavender = showString "lavender"
| c == lavenderblush = showString "lavenderblush"
| c == lawngreen = showString "lawngreen"
| c == lemonchiffon = showString "lemonchiffon"
| c == lightblue = showString "lightblue"
| c == lightcoral = showString "lightcoral"
| c == lightcyan = showString "lightcyan"
| c == lightgoldenrodyellow= showString "lightgoldenrodyellow"
| c == lightgreen = showString "lightgreen"
| c == lightgray = showString "lightgray"
| c == lightpink = showString "lightpink"
| c == lightsalmon = showString "lightsalmon"
| c == lightseagreen = showString "lightseagreen"
| c == lightskyblue = showString "lightskyblue"
| c == lightslategray = showString "lightslategray"
| c == lightsteelblue = showString "lightsteelblue"
| c == lightyellow = showString "lightyellow"
| c == lime = showString "lime"
| c == limegreen = showString "limegreen"
| c == linen = showString "linen"
| c == magenta = showString "magenta"
| c == maroon = showString "maroon"
| c == mediumaquamarine = showString "mediumaquamarine"
| c == mediumblue = showString "mediumblue"
| c == mediumorchid = showString "mediumorchid"
| c == mediumpurple = showString "mediumpurple"
| c == mediumseagreen = showString "mediumseagreen"
| c == mediumslateblue = showString "mediumslateblue"
| c == mediumspringgreen = showString "mediumspringgreen"
| c == mediumturquoise = showString "mediumturquoise"
| c == mediumvioletred = showString "mediumvioletred"
| c == midnightblue = showString "midnightblue"
| c == mintcream = showString "mintcream"
| c == mistyrose = showString "mistyrose"
| c == moccasin = showString "moccasin"
| c == navajowhite = showString "navajowhite"
| c == navy = showString "navy"
| c == oldlace = showString "oldlace"
| c == olive = showString "olive"
| c == olivedrab = showString "olivedrab"
| c == orange = showString "orange"
| c == orangered = showString "orangered"
| c == orchid = showString "orchid"
| c == palegoldenrod = showString "palegoldenrod"
| c == palegreen = showString "palegreen"
| c == paleturquoise = showString "paleturquoise"
| c == palevioletred = showString "palevioletred"
| c == papayawhip = showString "papayawhip"
| c == peachpuff = showString "peachpuff"
| c == peru = showString "peru"
| c == pink = showString "pink"
| c == plum = showString "plum"
| c == powderblue = showString "powderblue"
| c == purple = showString "purple"
| c == red = showString "red"
| c == rosybrown = showString "rosybrown"
| c == royalblue = showString "royalblue"
| c == saddlebrown = showString "saddlebrown"
| c == salmon = showString "salmon"
| c == sandybrown = showString "sandybrown"
| c == seagreen = showString "seagreen"
| c == seashell = showString "seashell"
| c == sienna = showString "sienna"
| c == silver = showString "silver"
| c == skyblue = showString "skyblue"
| c == slateblue = showString "slateblue"
| c == slategray = showString "slategray"
| c == snow = showString "snow"
| c == springgreen = showString "springgreen"
| c == steelblue = showString "steelblue"
| c == teal = showString "teal"
| c == thistle = showString "thistle"
| c == tomato = showString "tomato"
| c == turquoise = showString "turquoise"
| c == violet = showString "violet"
| c == wheat = showString "wheat"
| c == white = showString "white"
| c == whitesmoke = showString "whitesmoke"
| c == yellow = showString "yellow"
| c == yellowgreen = showString "yellowgreen"
| c == dialoggray = showString "dialoggray"
| otherwise = showParen (d > 0)
(showString "rgbColor " . shows (colorRed c) .
showChar ' ' . shows (colorGreen c) .
showChar ' ' . shows (colorBlue c))
-- | Create a color from a red\/green\/blue triple.
rgbColor :: Word8 -> Word8 -> Word8 -> Color
rgbColor r g b = Color (((fromIntegral b) * 0x10000) .|. ((fromIntegral g) * 0x100) .|. fromIntegral r)
-- | Returns a red color component
colorRed :: Color -> Word8
colorRed (Color c) = fromIntegral ((c ) .&. 0xFF)
-- | Returns a green color component
colorGreen :: Color -> Word8
colorGreen (Color c) = fromIntegral ((c `div` 0x100 ) .&. 0xFF)
-- | Returns a blue color component
colorBlue :: Color -> Word8
colorBlue (Color c) = fromIntegral ((c `div` 0x10000) .&. 0xFF)
-- Default colors.
aliceblue, antiquewhite, aqua, aquamarine, azure, beige,
bisque, black, blanchedalmond, blue, blueviolet, brown,
burlywood, cadetblue, chartreuse, chocolate, coral,
cornflower, cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgreen, darkkhaki,
darkmagenta, darkolivegreen, darkorange, darkorchid,
darkred, darksalmon, darkseagreen, darkslateblue,
darkslategray, darkturquoise, darkviolet, deeppink,
deepskyblue, dimgray, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, green, greenyellow,
honeydew, hotpink, indianred, indigo, ivory, khaki,
lavender, lavenderblush, lawngreen, lemonchiffon,
lightblue, lightcoral, lightcyan, lightgoldenrodyellow,
lightgreen, lightgray, lightpink, lightsalmon,
lightseagreen, lightskyblue, lightslategray,
lightsteelblue, lightyellow, lime,
limegreen, linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple, mediumseagreen,
mediumslateblue, mediumspringgreen, mediumturquoise,
mediumvioletred, midnightblue, mintcream, mistyrose,
moccasin, navajowhite, navy, oldlace, olive, olivedrab,
orange, orangered, orchid, palegoldenrod, palegreen,
paleturquoise, palevioletred, papayawhip, peachpuff,
peru, pink, plum, powderblue, purple, red, rosybrown,
royalblue, saddlebrown, salmon, sandybrown, seagreen,
seashell, sienna, silver, skyblue, slateblue, slategray,
snow, springgreen, steelblue, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke, yellow,
yellowgreen, dialoggray :: Color
aliceblue = Color 0xFFF8F0
antiquewhite = Color 0xD7EBFA
aqua = Color 0xFFFF00
aquamarine = Color 0xD4FF7F
azure = Color 0xFFFFF0
beige = Color 0xDCF5F5
bisque = Color 0xFFE4C4
black = Color 0x000000
blanchedalmond = Color 0xCDEBFF
blue = Color 0xFF0000
blueviolet = Color 0xE22B8A
brown = Color 0x2A2AA5
burlywood = Color 0x87B8DE
cadetblue = Color 0xA09E5F
chartreuse = Color 0x00FF7F
chocolate = Color 0x1E69D2
coral = Color 0x507FFF
cornflower = Color 0xED9564
cornsilk = Color 0xDCF8FF
crimson = Color 0x3C14DC
cyan = Color 0xFFFF00
darkblue = Color 0x8B0000
darkcyan = Color 0x8B8B00
darkgoldenrod = Color 0x0B86B8
darkgray = Color 0xA9A9A9
darkgreen = Color 0x006400
darkkhaki = Color 0xBDB76B
darkmagenta = Color 0x8B008B
darkolivegreen = Color 0x2F6B55
darkorange = Color 0x008CFF
darkorchid = Color 0xCC3299
darkred = Color 0x00008B
darksalmon = Color 0x7A96E9
darkseagreen = Color 0x8BBC8F
darkslateblue = Color 0x8B3D48
darkslategray = Color 0x4F4F2F
darkturquoise = Color 0xD1CE00
darkviolet = Color 0xD30094
deeppink = Color 0x9314FF
deepskyblue = Color 0xFFBF00
dimgray = Color 0x696969
dodgerblue = Color 0xFF901E
firebrick = Color 0x2222B2
floralwhite = Color 0xF0FAFF
forestgreen = Color 0x228B22
fuchsia = Color 0xFF00FF
gainsboro = Color 0xDCDCDC
ghostwhite = Color 0xFFF8F8
gold = Color 0x00D7FF
goldenrod = Color 0x20A5DA
gray = Color 0x808080
green = Color 0x008000
greenyellow = Color 0x2FFFAD
honeydew = Color 0xF0FFF0
hotpink = Color 0xB469FF
indianred = Color 0x5C5CCD
indigo = Color 0x82004B
ivory = Color 0xF0FFFF
khaki = Color 0x8CE6F0
lavender = Color 0xFAE6E6
lavenderblush = Color 0xF5F0FF
lawngreen = Color 0x00FC7C
lemonchiffon = Color 0xCDFAFF
lightblue = Color 0xE6D8AD
lightcoral = Color 0x8080F0
lightcyan = Color 0xFFFFE0
lightgoldenrodyellow= Color 0xD2FAFA
lightgreen = Color 0x90EE90
lightgray = Color 0xD3D3D3
lightpink = Color 0xC1B6FF
lightsalmon = Color 0x7AA0FF
lightseagreen = Color 0xAAB220
lightskyblue = Color 0xFACE87
lightslategray = Color 0x998877
lightsteelblue = Color 0xDEC4B0
lightyellow = Color 0xE0FFFF
lime = Color 0x00FF00
limegreen = Color 0x32CD32
linen = Color 0xE6F0FA
magenta = Color 0xFF00FF
maroon = Color 0x000080
mediumaquamarine = Color 0xAACD66
mediumblue = Color 0xCD0000
mediumorchid = Color 0xD355BA
mediumpurple = Color 0xDB7093
mediumseagreen = Color 0x71B33C
mediumslateblue = Color 0xEE687B
mediumspringgreen = Color 0x9AFA00
mediumturquoise = Color 0xCCD148
mediumvioletred = Color 0x8515C7
midnightblue = Color 0x701919
mintcream = Color 0xFAFFF5
mistyrose = Color 0xE1E4FF
moccasin = Color 0xB5E4FF
navajowhite = Color 0xADDEFF
navy = Color 0x800000
oldlace = Color 0xE6F5FD
olive = Color 0x008080
olivedrab = Color 0x238E6B
orange = Color 0x00A5FF
orangered = Color 0x0045FF
orchid = Color 0xD670DA
palegoldenrod = Color 0xAAE8EE
palegreen = Color 0x98FB98
paleturquoise = Color 0xEEEEAF
palevioletred = Color 0x9370DB
papayawhip = Color 0xD5EFFF
peachpuff = Color 0xB9DAFF
peru = Color 0x3F85CD
pink = Color 0xCBC0FF
plum = Color 0xDDA0DD
powderblue = Color 0xE6E0B0
purple = Color 0x800080
red = Color 0x0000FF
rosybrown = Color 0x8F8FBC
royalblue = Color 0xE16941
saddlebrown = Color 0x13458B
salmon = Color 0x7280FA
sandybrown = Color 0x60A4F4
seagreen = Color 0x578B2E
seashell = Color 0xEEF5FF
sienna = Color 0x2D52A0
silver = Color 0xC0C0C0
skyblue = Color 0xEBCE87
slateblue = Color 0xCD5A6A
slategray = Color 0x908070
snow = Color 0xFAFAFF
springgreen = Color 0x7FFF00
steelblue = Color 0xB48246
teal = Color 0x808000
thistle = Color 0xD8BFD8
tomato = Color 0x4763FF
turquoise = Color 0xD0E040
violet = Color 0xEE82EE
wheat = Color 0xB3DEF5
white = Color 0xFFFFFF
whitesmoke = Color 0xF5F5F5
yellow = Color 0x00FFFF
yellowgreen = Color 0x32CD9A
dialoggray = Color 0xC8D0D4
-- marshalling
type CColor = CUInt
toCColor :: Color -> CColor
toCColor (Color c) = fromIntegral c
fromCColor :: CColor -> Color
fromCColor cx = Color (fromIntegral cx)
Index: Canvas.hs
===================================================================
RCS file: /cvsroot/htoolkit/port/src/Port/Canvas.hs,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Canvas.hs 8 Feb 2003 08:36:14 -0000 1.12
--- Canvas.hs 15 Mar 2003 01:06:32 -0000 1.13
***************
*** 93,97 ****
dialogPen :: Pen
dialogPen
! = Pen 1 DrawCopy black dialoggrey False dialogFont JoinMiter CapFlat LineSolid HatchSolid
--- 93,97 ----
dialogPen :: Pen
dialogPen
! = Pen 1 DrawCopy black dialoggray False dialogFont JoinMiter CapFlat LineSolid HatchSolid
***************
*** 117,121 ****
(toCBufferMode buffermode)
! foreign import ccall osInitCanvas :: CInt -> CInt -> CWord -> CWord
-> CInt -> CInt
-> CInt -> CInt -> Ptr CUChar
--- 117,121 ----
(toCBufferMode buffermode)
! foreign import ccall osInitCanvas :: CInt -> CInt -> CColor -> CColor
-> CInt -> CInt
-> CInt -> CInt -> Ptr CUChar
***************
*** 150,154 ****
cfont
canvas
! foreign import ccall osChangeCanvasPen :: CInt -> CInt -> CWord -> CWord
-> CInt -> CInt
-> CInt -> CInt -> Ptr CUChar
--- 150,154 ----
cfont
canvas
! foreign import ccall osChangeCanvasPen :: CInt -> CInt -> CColor -> CColor
-> CInt -> CInt
-> CInt -> CInt -> Ptr CUChar
Index: ColorDialog.hs
===================================================================
RCS file: /cvsroot/htoolkit/port/src/Port/ColorDialog.hs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ColorDialog.hs 14 Mar 2003 18:38:43 -0000 1.1
--- ColorDialog.hs 15 Mar 2003 01:06:32 -0000 1.2
***************
*** 27,29 ****
return (Just (fromCColor c))
else return Nothing
! foreign import ccall osRunColorDialog :: Ptr CWord -> IO Bool
--- 27,29 ----
return (Just (fromCColor c))
else return Nothing
! foreign import ccall osRunColorDialog :: Ptr CColor -> IO Bool
Index: Types.hs
===================================================================
RCS file: /cvsroot/htoolkit/port/src/Port/Types.hs,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** Types.hs 10 Feb 2003 22:42:09 -0000 1.13
--- Types.hs 15 Mar 2003 01:06:32 -0000 1.14
***************
*** 36,46 ****
-- ** Colors
! , Color
! , rgbColor, colorRed, colorGreen, colorBlue
!
! -- *** Standard colors
! , black, darkgrey, grey, lightgrey, dialoggrey, white
! , red, green, blue
! , cyan, magenta, yellow
-- ** Bitmaps
--- 36,40 ----
-- ** Colors
! , module Graphics.UI.Port.Colors
-- ** Bitmaps
***************
*** 101,105 ****
, withCFontMetricsResult, fromCFontMetrics
- , fromCColor, toCColor
, withCPoint, fromCPoint
, withCSize, withCSizeResult, fromCSize
--- 95,98 ----
***************
*** 123,129 ****
import Foreign.Marshal.Alloc
import System.IO( bracket )
- import Data.Word
import Data.Bits
!
{-----------------------------------------------------------------------------------------
--- 116,121 ----
import Foreign.Marshal.Alloc
import System.IO( bracket )
import Data.Bits
! import Graphics.UI.Port.Colors
{-----------------------------------------------------------------------------------------
***************
*** 158,231 ****
nullHandle
= nullPtr
-
- {-----------------------------------------------------------------------------------------
- Color
- -----------------------------------------------------------------------------------------}
- -- | An abstract data type to define colors.
- newtype Color = Color Word deriving Eq
-
- instance Show Color where
- showsPrec d c
- | c == black = showString "black"
- | c == darkgrey = showString "darkgrey"
- | c == grey = showString "grey"
- | c == lightgrey= showString "lightgrey"
- | c == white = showString "white"
- | c == red = showString "red"
- | c == green = showString "green"
- | c == blue = showString "blue"
- | c == cyan = showString "cyan"
- | c == magenta = showString "magenta"
- | c == yellow = showString "yellow"
- | otherwise = showParen (d > 0)
- (showString "rgbColor " . shows (colorRed c) .
- showChar ' ' . shows (colorGreen c) .
- showChar ' ' . shows (colorBlue c))
-
- -- | Create a color from a red\/green\/blue triple.
- rgbColor :: Word8 -> Word8 -> Word8 -> Color
- rgbColor r g b = Color (((fromIntegral b) * 0x10000) .|. ((fromIntegral g) * 0x100) .|. fromIntegral r)
-
- -- | Returns a red color component
- colorRed :: Color -> Word8
- colorRed (Color c) = fromIntegral ((c ) .&. 0xFF)
-
- -- | Returns a green color component
- colorGreen :: Color -> Word8
- colorGreen (Color c) = fromIntegral ((c `div` 0x100 ) .&. 0xFF)
-
- -- | Returns a blue color component
- colorBlue :: Color -> Word8
- colorBlue (Color c) = fromIntegral ((c `div` 0x10000) .&. 0xFF)
-
-
- -- Default colors.
- black, darkgrey, grey, lightgrey, white :: Color
- red, green, blue :: Color
- cyan, magenta, yellow, dialoggrey :: Color
-
- black = Color 0x000000
- darkgrey = Color 0x3F3F3F
- grey = Color 0x7F7F7F
- lightgrey = Color 0xBFBFBF
- white = Color 0xFFFFFF
-
- red = Color 0x0000FF
- green = Color 0x00FF00
- blue = Color 0xFF0000
-
- cyan = Color 0xFFFF00
- magenta = Color 0xFF00FF
- yellow = Color 0x00FFFF
-
- dialoggrey= Color 0xC8D0D4
-
- -- marshalling
- toCColor :: Color -> CWord
- toCColor (Color c) = fromIntegral c
-
- fromCColor :: CWord -> Color
- fromCColor cx = Color (fromIntegral cx)
-
{-----------------------------------------------------------------------------------------
--- 150,153 ----
|