{-# LANGUAGE CPP #-}
module DDisplayF(
setSpacer,
DisplayF,
displayF,displayF',
intDispF,intDispF',
labelF,labelF'
) where
import FDefaults
import GraphicsF(graphicsDispF',replaceAllGfx,setGfxEventMask)
import Graphic
import Drawing()
import DrawingUtils(spacedD,g)
import GCAttrs
import NullF(F)
import ResourceIds()
import Defaults(defaultFont,labelFont,paperColor,fgColor,bgColor)
import CmdLineEnv(argKeyList)
import CompOps((>=^^<),(>=^<),(>^^=<))
import CompSP(idLeftSP)
import Spops(nullSP)
import SpEither(filterRightSP)
import Alignment(aRight,aLeft,aCenter)
import Spacers(marginS,compS,hAlignS)
import LayoutRequest(Spacer)
import Sizing(Sizing(..))
import CondLayout(alignFixedS')
#include "defaults.h"
newtype DisplayF a = Pars [Pars a]
data Pars a
= BorderWidth Int
| FgColorSpec ColorSpec
| BgColorSpec ColorSpec
| FontSpec FontSpec
| Spacer Spacer
| Margin Int
| InitDisp a
| InitSize a
| Sizing Sizing
| Stretchable (Bool,Bool)
type StringDisplayF = DisplayF String
parameter_instance1(BorderWidth,DisplayF)
parameter_instance1(FgColorSpec,DisplayF)
parameter_instance1(BgColorSpec,DisplayF)
parameter_instance1(FontSpec,DisplayF)
parameter_instance1(Margin,DisplayF)
parameter_instance(InitDisp,DisplayF)
setSpacer :: Spacer -> Customiser (DisplayF a)
parameter(Spacer)
parameter_instance(InitSize,DisplayF)
parameter_instance1(Stretchable,DisplayF)
parameter_instance1(Sizing,DisplayF)
instance HasAlign (DisplayF a) where
setAlign :: Alignment -> Customiser (DisplayF a)
setAlign Alignment
align (Pars [Pars a]
ps) = forall a. [Pars a] -> DisplayF a
Pars (forall a. Spacer -> Pars a
Spacer (Alignment -> Alignment -> Spacer
alignFixedS' Alignment
align Alignment
aCenter)forall a. a -> [a] -> [a]
:[Pars a]
ps)
labelDisplayF :: Graphic g => F g void
labelDisplayF :: forall g void. Graphic g => F g void
labelDisplayF = forall {a} {b}. Graphic a => Customiser (DisplayF a) -> F a b
labelDisplayF' forall a. Customiser a
standard
labelDisplayF' :: Customiser (DisplayF a) -> F a b
labelDisplayF' Customiser (DisplayF a)
pm = forall p a b. PF p a b -> F a b
noPF forall a b. (a -> b) -> a -> b
$ forall g void.
Graphic g =>
Customiser (DisplayF g) -> PF (DisplayF g) g void
labelDisplayF'' Customiser (DisplayF a)
pm
labelDisplayF''
:: Graphic g => Customiser (DisplayF g) -> PF (DisplayF g) g void
labelDisplayF'' :: forall g void.
Graphic g =>
Customiser (DisplayF g) -> PF (DisplayF g) g void
labelDisplayF'' Customiser (DisplayF g)
pmod =
forall a b. SP a b
nullSP forall a b e. SP a b -> F e a -> F e b
>^^=<
forall gfx.
Graphic gfx =>
Customiser (GraphicsF gfx) -> F (GfxFCmd gfx) GfxFEvent
graphicsDispF' forall {lbl}.
GraphicsF (Drawing lbl Gfx) -> GraphicsF (Drawing lbl Gfx)
custom forall c d e. F c d -> (e -> c) -> F e d
>=^<
forall {a} {lbl}. g -> GfxCommand [a] (Drawing lbl Gfx)
pre forall c d e. F c d -> SP e c -> F e d
>=^^<
forall {a1} {b}. SP (Either a1 b) b
filterRightSP
where
custom :: GraphicsF (Drawing lbl Gfx) -> GraphicsF (Drawing lbl Gfx)
custom =
forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. Customiser a
id (forall (xxx :: * -> *) a.
HasInitDisp xxx =>
a -> Customiser (xxx a)
setInitDisp forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {lbl}. g -> Drawing lbl Gfx
draw) Maybe g
initDisp forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. Customiser a
id (forall (xxx :: * -> *) a.
HasInitSize xxx =>
a -> Customiser (xxx a)
setInitSize forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {lbl}. g -> Drawing lbl Gfx
draw) Maybe g
initSize forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall {gfx}. [GfxEventMask] -> Customiser (GraphicsF gfx)
setGfxEventMask [] forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall xxx. HasSizing xxx => Sizing -> Customiser xxx
setSizing Sizing
sizing forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall xxx. HasBorderWidth xxx => Int -> Customiser xxx
setBorderWidth Int
borderWidth forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall xxx. HasBgColorSpec xxx => ColorSpec -> Customiser xxx
setBgColorSpec ColorSpec
bgColor forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall {xxx} {a}.
(HasFontSpec xxx, Show a, FontGen a) =>
a -> Customiser xxx
setFont FontSpec
font forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall xxx. HasFgColorSpec xxx => ColorSpec -> Customiser xxx
setFgColorSpec ColorSpec
fgColor forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall xxx. HasStretchable xxx => (Bool, Bool) -> Customiser xxx
setStretchable (Bool, Bool)
stretch
pre :: g -> GfxCommand [a] (Drawing lbl Gfx)
pre = forall {gfx} {a}. gfx -> GfxCommand [a] gfx
replaceAllGfx forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {lbl}. g -> Drawing lbl Gfx
draw
draw :: g -> Drawing lbl Gfx
draw = forall {lbl} {leaf}. Drawing lbl leaf -> Drawing lbl leaf
marginD forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {a} {lbl}. Graphic a => a -> Drawing lbl Gfx
g
marginD :: Drawing lbl leaf -> Drawing lbl leaf
marginD = forall {lbl} {leaf}. Spacer -> Drawing lbl leaf -> Drawing lbl leaf
spacedD (Int -> Spacer
marginS Int
margin Spacer -> Spacer -> Spacer
`compS` Spacer
spacer)
margin :: Int
margin = forall xxx. HasMargin xxx => xxx -> Int
getMargin DisplayF g
ps
borderWidth :: Int
borderWidth = forall xxx. HasBorderWidth xxx => xxx -> Int
getBorderWidth DisplayF g
ps
bgColor :: ColorSpec
bgColor = forall xxx. HasBgColorSpec xxx => xxx -> ColorSpec
getBgColorSpec DisplayF g
ps
fgColor :: ColorSpec
fgColor = forall xxx. HasFgColorSpec xxx => xxx -> ColorSpec
getFgColorSpec DisplayF g
ps
font :: FontSpec
font = forall xxx. HasFontSpec xxx => xxx -> FontSpec
getFontSpec DisplayF g
ps
spacer :: Spacer
spacer = forall {a}. DisplayF a -> Spacer
getSpacer DisplayF g
ps
stretch :: (Bool, Bool)
stretch = forall xxx. HasStretchable xxx => xxx -> (Bool, Bool)
getStretchable DisplayF g
ps
sizing :: Sizing
sizing = forall xxx. HasSizing xxx => xxx -> Sizing
getSizing DisplayF g
ps
initSize :: Maybe g
initSize = forall (xxx :: * -> *) a. HasInitSize xxx => xxx a -> Maybe a
getInitSizeMaybe DisplayF g
ps
initDisp :: Maybe g
initDisp = forall (xxx :: * -> *) a. HasInitDisp xxx => xxx a -> Maybe a
getInitDispMaybe DisplayF g
ps
ps :: DisplayF g
ps = Customiser (DisplayF g)
pmod (forall a. [Pars a] -> DisplayF a
Pars [forall a. Int -> Pars a
Margin Int
4,forall a. Int -> Pars a
BorderWidth Int
0,
forall a. ColorSpec -> Pars a
FgColorSpec ColorSpec
dispfg, forall a. ColorSpec -> Pars a
BgColorSpec ColorSpec
dispbg,
forall a. FontSpec -> Pars a
FontSpec (forall {a}. (Show a, FontGen a) => a -> FontSpec
fontSpec FontName
defaultFont),
forall a. Spacer -> Pars a
Spacer (Alignment -> Alignment -> Spacer
alignFixedS' Alignment
aLeft Alignment
aCenter),
forall a. (Bool, Bool) -> Pars a
Stretchable (Bool
False,Bool
False),
forall a. Sizing -> Pars a
Sizing Sizing
Dynamic])
displayF :: Graphic g => F g void
displayF :: forall g void. Graphic g => F g void
displayF = forall {a} {b}. Graphic a => Customiser (DisplayF a) -> F a b
displayF' forall a. Customiser a
standard
displayF' :: Customiser (DisplayF a) -> F a b
displayF' Customiser (DisplayF a)
custom = forall p a b. PF p a b -> F a b
noPF forall a b. (a -> b) -> a -> b
$ forall g void.
Graphic g =>
Customiser (DisplayF g) -> PF (DisplayF g) g void
displayF'' Customiser (DisplayF a)
custom
displayF'' :: Graphic g => Customiser (DisplayF g) -> PF (DisplayF g) g void
displayF'' :: forall g void.
Graphic g =>
Customiser (DisplayF g) -> PF (DisplayF g) g void
displayF'' Customiser (DisplayF g)
pmod = forall g void.
Graphic g =>
Customiser (DisplayF g) -> PF (DisplayF g) g void
labelDisplayF'' Customiser (DisplayF g)
pmod'
where
pmod' :: Customiser (DisplayF g)
pmod' = Customiser (DisplayF g)
pmod forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall xxx. HasBorderWidth xxx => Int -> Customiser xxx
setBorderWidth Int
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall xxx. HasStretchable xxx => (Bool, Bool) -> Customiser xxx
setStretchable (Bool
True,Bool
False) forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall {a}. Spacer -> Customiser (DisplayF a)
setSpacer (Alignment -> Spacer
hAlignS Alignment
aLeft) forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall xxx. HasSizing xxx => Sizing -> Customiser xxx
setSizing Sizing
Growing
labelF :: a -> F a b
labelF a
lbl = forall {a} {a} {b}.
Graphic a =>
Customiser (DisplayF a) -> a -> F a b
labelF' forall a. Customiser a
standard a
lbl
labelF' :: Customiser (DisplayF a) -> a -> F a b
labelF' Customiser (DisplayF a)
pm = forall p a b. PF p a b -> F a b
noPF forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall g a b.
Graphic g =>
Customiser (DisplayF g) -> g -> PF (DisplayF g) a b
labelF'' Customiser (DisplayF a)
pm
labelF'' :: Graphic g => Customiser (DisplayF g) -> g -> PF (DisplayF g) a b
labelF'' :: forall g a b.
Graphic g =>
Customiser (DisplayF g) -> g -> PF (DisplayF g) a b
labelF'' Customiser (DisplayF g)
pmod g
lbl = forall g void.
Graphic g =>
Customiser (DisplayF g) -> PF (DisplayF g) g void
labelDisplayF'' Customiser (DisplayF g)
pmod' forall c d e. F c d -> SP e c -> F e d
>=^^< forall {a1} {b} {a2}. SP a1 b -> SP (Either a2 a1) (Either a2 b)
idLeftSP forall a b. SP a b
nullSP
where
pmod' :: Customiser (DisplayF g)
pmod' = Customiser (DisplayF g)
pmodforall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall (xxx :: * -> *) a.
HasInitDisp xxx =>
a -> Customiser (xxx a)
setInitDisp g
lblforall b c a. (b -> c) -> (a -> b) -> a -> c
.
(forall {xxx} {p}.
(HasFgColorSpec xxx, Show p, ColorGen p) =>
p -> Customiser xxx
setFgColor ColorSpec
lblfg::(Customiser (DisplayF g)))forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall {xxx} {p}.
(HasBgColorSpec xxx, Show p, ColorGen p) =>
p -> Customiser xxx
setBgColor ColorSpec
lblbgforall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall {xxx} {a}.
(HasFontSpec xxx, Show a, FontGen a) =>
a -> Customiser xxx
setFont FontName
labelFontforall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall xxx. HasMargin xxx => Int -> Customiser xxx
setMargin Int
0 forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall xxx. HasSizing xxx => Sizing -> Customiser xxx
setSizing Sizing
Static
intDispF :: F Int b
intDispF = forall {b}. Customiser (DisplayF Int) -> F Int b
intDispF' forall a. Customiser a
standard
intDispF' :: Customiser (DisplayF Int) -> F Int b
intDispF' = forall p a b. PF p a b -> F a b
noPF forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Customiser (DisplayF Int) -> PF (DisplayF Int) Int a
intDispF''
intDispF'' :: Customiser (DisplayF Int) -> PF (DisplayF Int) Int a
intDispF'' :: forall a. Customiser (DisplayF Int) -> PF (DisplayF Int) Int a
intDispF'' Customiser (DisplayF Int)
pm = forall g void.
Graphic g =>
Customiser (DisplayF g) -> PF (DisplayF g) g void
displayF'' (Int -> Customiser (DisplayF Int)
pm' Int
0)
where pm' :: Int -> Customiser (DisplayF Int)
pm' Int
x = Customiser (DisplayF Int)
pmforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall xxx. HasAlign xxx => Alignment -> Customiser xxx
setAlign Alignment
aRight
forall b c a. (b -> c) -> (a -> b) -> a -> c
.forall (xxx :: * -> *) a.
HasInitDisp xxx =>
a -> Customiser (xxx a)
setInitDisp Int
x
forall b c a. (b -> c) -> (a -> b) -> a -> c
.forall (xxx :: * -> *) a.
HasInitSize xxx =>
a -> Customiser (xxx a)
setInitSize ((-forall a. Bounded a => a
maxBound) forall a. a -> a -> a
`asTypeOf` Int
x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(forall xxx. HasSizing xxx => Sizing -> Customiser xxx
setSizing Sizing
Static::(Customiser (DisplayF Int)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.forall xxx. HasStretchable xxx => (Bool, Bool) -> Customiser xxx
setStretchable (Bool
False,Bool
False)
dispbg :: ColorSpec
dispbg = forall {a}. (Show a, ColorGen a) => a -> ColorSpec
colorSpec (FontName -> [FontName] -> [FontName]
argKeyList FontName
"dispbg" [FontName
paperColor,FontName
"white"])
dispfg :: ColorSpec
dispfg = forall {a}. (Show a, ColorGen a) => a -> ColorSpec
colorSpec (FontName -> [FontName] -> [FontName]
argKeyList FontName
"dispfg" [FontName
fgColor,FontName
"black"])
lblbg :: ColorSpec
lblbg = forall {a}. (Show a, ColorGen a) => a -> ColorSpec
colorSpec (FontName -> [FontName] -> [FontName]
argKeyList FontName
"lblbg" [FontName
bgColor,FontName
"white"])
lblfg :: ColorSpec
lblfg = forall {a}. (Show a, ColorGen a) => a -> ColorSpec
colorSpec (FontName -> [FontName] -> [FontName]
argKeyList FontName
"lblfg" [FontName
fgColor,FontName
"black"])