{-# LANGUAGE CPP #-}
module DButtonF(
  ButtonF,buttonF,buttonF',buttonF'',setLabel
  ) where
import FDefaults
import ButtonF(oldButtonF)
--import Fudget
--import Geometry(Rect)
import PushButtonF(Click)
import Xtypes
import Defaults(buttonFont,fgColor,bgColor)
import CmdLineEnv(argKeyList)
import CompOps((>^=<),(>=^^<))
--import Spops(concmapSP)
import SpEither(mapFilterSP)--filterRightSP
import EitherUtils(stripEither)
import SerCompF(idRightF)
import Spacers(Distance(..))
import Alignment(aCenter) --,Alignment(..)
import Graphic
import GCAttrs --(ColorSpec,colorSpec) -- + instances

#include "defaults.h"

newtype ButtonF lbl = Pars [Pars lbl]
data Pars lbl
  = FontSpec FontSpec
  | Keys [(ModState, KeySym)]
  | FgColorSpec ColorSpec
  | BgColorSpec ColorSpec
  | Margin Distance
  | Align Alignment
  | Label lbl

parameter_instance1(FontSpec,ButtonF)
parameter_instance1(Keys,ButtonF)
parameter_instance1(FgColorSpec,ButtonF)
parameter_instance1(BgColorSpec,ButtonF)
parameter_instance1(Margin,ButtonF)
parameter_instance1(Align,ButtonF)
parameterlbl
(Label)

buttonF :: lbl -> F Click Click
buttonF lbl
s = Customiser (ButtonF lbl) -> lbl -> F Click Click
forall lbl.
Graphic lbl =>
Customiser (ButtonF lbl) -> lbl -> F Click Click
buttonF' Customiser (ButtonF lbl)
forall a. Customiser a
standard lbl
s
buttonF' :: Customiser (ButtonF lbl) -> lbl -> F Click Click
buttonF' Customiser (ButtonF lbl)
pm lbl
s = PF (ButtonF lbl) Click Click -> F Click Click
forall p a b. PF p a b -> F a b
noPF (PF (ButtonF lbl) Click Click -> F Click Click)
-> PF (ButtonF lbl) Click Click -> F Click Click
forall a b. (a -> b) -> a -> b
$ Customiser (ButtonF lbl) -> lbl -> PF (ButtonF lbl) Click Click
forall lbl.
Graphic lbl =>
Customiser (ButtonF lbl) -> lbl -> PF (ButtonF lbl) Click Click
buttonF'' Customiser (ButtonF lbl)
pm lbl
s

buttonF'' ::
  Graphic lbl => Customiser (ButtonF lbl) -> lbl -> PF (ButtonF lbl) Click Click
buttonF'' :: Customiser (ButtonF lbl) -> lbl -> PF (ButtonF lbl) Click Click
buttonF'' Customiser (ButtonF lbl)
pmod lbl
s =
    Either Click Click -> Click
forall p. Either p p -> p
stripEither (Either Click Click -> Click)
-> F (Either (Customiser (ButtonF lbl)) Click) (Either Click Click)
-> PF (ButtonF lbl) Click Click
forall a b e. (a -> b) -> F e a -> F e b
>^=<
    F (Customiser (ButtonF lbl)) Click
-> F (Either (Customiser (ButtonF lbl)) Click) (Either Click Click)
forall a b c. F a b -> F (Either a c) (Either b c)
idRightF (Alignment
-> Int
-> FontSpec
-> ColorSpec
-> ColorSpec
-> [(ModState, KeySym)]
-> lbl
-> F lbl Click
forall e a1 a2.
(Graphic e, FontGen a1, Show a1, Show a2, ColorGen a2) =>
Alignment
-> Int
-> a1
-> ColorSpec
-> a2
-> [(ModState, KeySym)]
-> e
-> F e Click
oldButtonF Alignment
align Int
marg FontSpec
font ColorSpec
bg ColorSpec
fg [(ModState, KeySym)]
keys lbl
lbl F lbl Click
-> SP (Customiser (ButtonF lbl)) lbl
-> F (Customiser (ButtonF lbl)) Click
forall c d e. F c d -> SP e c -> F e d
>=^^< (Customiser (ButtonF lbl) -> Maybe lbl)
-> SP (Customiser (ButtonF lbl)) lbl
forall t b. (t -> Maybe b) -> SP t b
mapFilterSP Customiser (ButtonF lbl) -> Maybe lbl
forall lbl a. (ButtonF lbl -> ButtonF a) -> Maybe a
relbl)
  where
    lbl :: lbl
lbl  = ButtonF lbl -> lbl
forall c. ButtonF c -> c
getLabel ButtonF lbl
ps
    font :: FontSpec
font = ButtonF lbl -> FontSpec
forall xxx. HasFontSpec xxx => xxx -> FontSpec
getFontSpec ButtonF lbl
ps
    keys :: [(ModState, KeySym)]
keys = ButtonF lbl -> [(ModState, KeySym)]
forall xxx. HasKeys xxx => xxx -> [(ModState, KeySym)]
getKeys ButtonF lbl
ps
    ps :: ButtonF lbl
ps   = Customiser (ButtonF lbl)
pmod ButtonF lbl
ps0
    bg :: ColorSpec
bg   = ButtonF lbl -> ColorSpec
forall xxx. HasBgColorSpec xxx => xxx -> ColorSpec
getBgColorSpec ButtonF lbl
ps
    fg :: ColorSpec
fg   = ButtonF lbl -> ColorSpec
forall xxx. HasFgColorSpec xxx => xxx -> ColorSpec
getFgColorSpec ButtonF lbl
ps
    marg :: Int
marg = ButtonF lbl -> Int
forall xxx. HasMargin xxx => xxx -> Int
getMargin ButtonF lbl
ps
    align :: Alignment
align = ButtonF lbl -> Alignment
forall xxx. HasAlign xxx => xxx -> Alignment
getAlign ButtonF lbl
ps
    ps0 :: ButtonF lbl
ps0  = [Pars lbl] -> ButtonF lbl
forall lbl. [Pars lbl] -> ButtonF lbl
Pars [FontSpec -> Pars lbl
forall lbl. FontSpec -> Pars lbl
FontSpec (KeySym -> FontSpec
forall a. (Show a, FontGen a) => a -> FontSpec
fontSpec KeySym
buttonFont), [(ModState, KeySym)] -> Pars lbl
forall lbl. [(ModState, KeySym)] -> Pars lbl
Keys [],Int -> Pars lbl
forall lbl. Int -> Pars lbl
Margin Int
2,Alignment -> Pars lbl
forall lbl. Alignment -> Pars lbl
Align Alignment
aCenter,
		 ColorSpec -> Pars lbl
forall lbl. ColorSpec -> Pars lbl
FgColorSpec ColorSpec
buttonfg, ColorSpec -> Pars lbl
forall lbl. ColorSpec -> Pars lbl
BgColorSpec ColorSpec
buttonbg, lbl -> Pars lbl
forall lbl. lbl -> Pars lbl
Label lbl
s]
    --relbl pmod' = [lbl | let Pars ps'=pmod' (Pars []), Label lbl<-ps']
    relbl :: (ButtonF lbl -> ButtonF a) -> Maybe a
relbl ButtonF lbl -> ButtonF a
pmod' = ButtonF a -> Maybe a
forall a. ButtonF a -> Maybe a
getLabelMaybe (ButtonF lbl -> ButtonF a
pmod' ([Pars lbl] -> ButtonF lbl
forall lbl. [Pars lbl] -> ButtonF lbl
Pars []))

buttonbg :: ColorSpec
buttonbg = [KeySym] -> ColorSpec
forall a. (Show a, ColorGen a) => a -> ColorSpec
colorSpec (KeySym -> [KeySym] -> [KeySym]
argKeyList KeySym
"buttonbg" [KeySym
bgColor,KeySym
"white"])
buttonfg :: ColorSpec
buttonfg = [KeySym] -> ColorSpec
forall a. (Show a, ColorGen a) => a -> ColorSpec
colorSpec (KeySym -> [KeySym] -> [KeySym]
argKeyList KeySym
"buttonfg" [KeySym
fgColor,KeySym
"black"])