WxGeneric 0.2.0 → 0.4.0
raw patch · 5 files changed
+16/−4 lines, 5 files
Files
- WxGeneric.cabal +1/−1
- src/Graphics/UI/WxGeneric/Composite.hs +2/−0
- src/Graphics/UI/WxGeneric/GenericClass.hs +6/−1
- src/Graphics/UI/WxGeneric/GenericList.hs +1/−1
- src/Graphics/UI/WxGeneric/GenericWidget.hs +6/−1
WxGeneric.cabal view
@@ -1,5 +1,5 @@ Name: WxGeneric-Version: 0.2.0+Version: 0.4.0 Copyright: Mads Lindstrøm <mads_lindstroem@yahoo.dk> License: LGPL License-file: COPYRIGHT.txt
src/Graphics/UI/WxGeneric/Composite.hs view
@@ -253,6 +253,8 @@ -- definition do not really work for widgets. It only seems to work -- for Var-s. class ValuedWidget x w | w -> x where+ -- |An attribute for the value of a widget. The value should have as precise+ -- a type as possible. For example a slider should properly have type Attr Slider Int. widgetValue :: Attr w x
src/Graphics/UI/WxGeneric/GenericClass.hs view
@@ -72,14 +72,17 @@ mapValue oldToNew newToOld (Outer lbl (Right genWidIO)) = Outer lbl (Right (\s w -> genWidIO s w >>= return . mapValue oldToNew newToOld)) +-- |Creates an 'Outer' type. The encapsulated widget is labelless. toOuter :: forall a. (WxGen a) => (forall w. Window w -> IO (GenWid a)) -> Outer a toOuter f = let priLabel = generateLabel (error "WxGeneric call to generateLabel (1)" :: a) in Outer priLabel (Left f) +-- |Creates an 'Outer' type. The encapsulated widget has a label. withLabel :: forall a. (WxGen a) => (String -> forall w. Window w -> IO (GenWid a)) -> Outer a withLabel f = let priLabel = generateLabel (error "WxGeneric call to generateLabel (2)" :: a) in Outer priLabel (Right f) +-- |Unpacks an 'Outer' type and returns the encapsulated 'GenWid'. fromOuter :: Window w -> Outer a -> IO (GenWid a) fromOuter w (Outer _ (Left f)) = f w fromOuter w (Outer lbl (Right f)) = f (labelString $ humanizeLabel lbl) w@@ -89,6 +92,7 @@ getUnlabeld (Outer lbl (Left _)) = Just $ labelString $ humanizeLabel lbl getUnlabeld (Outer _ (Right _)) = Nothing +-- |Sets the label on an 'Outer' type. setOuterLabel :: PriLabel -> Outer a -> Outer a setOuterLabel newLbl = updateLabel (const newLbl) @@ -124,6 +128,7 @@ data LabeledWid a = LabeledWid { lblWid :: (GenWid a), lblLabel :: Maybe String } +-- |Creates an 'Outer' type for a type with a single constructor. singleConstr :: WxGen a => a -> Outer a singleConstr x = genericCompose $ mkSpliterSingleConstr wxGenCtx (mkWidD dict) x where@@ -161,7 +166,7 @@ withoutLabels = map fst (snd sortedWidgets) in (map (\(lay,name) -> [label name, lay]) withLabels, withoutLabels) --- |Used for types with more than one constructor+-- |Creates an 'Outer' type for a type with more than one constructor. polyConstr :: forall a. (WxGen a, Data WxGenD a) => a -> Outer a polyConstr x = withLabel (\s -> valuedCompose (f s)) where
src/Graphics/UI/WxGeneric/GenericList.hs view
@@ -1,4 +1,4 @@--- |Exports an instance for 'WxGen' [a]. It handles [Char] (String) instances specially.+-- |Exports an instance for 'WxGen' [a]. It handles [Char] instances specially. module Graphics.UI.WxGeneric.GenericList ( )
src/Graphics/UI/WxGeneric/GenericWidget.hs view
@@ -86,7 +86,12 @@ -- *** MapValue class class MapValue (valued :: * -> *) where- mapValue :: (a -> b) -> (a -> b -> a) -> valued a -> valued b+ -- |Maps the value a type.+ mapValue :: (old -> new) -- ^old to new conversion+ -> (old -> new -> old) -- ^new to old conversion. This functions also get the current+ -- old value as input.+ -> valued old -- ^old type+ -> valued new -- ^new type instance MapValue GenWid where mapValue oldToNew newToOld (GenWid composite) =