From: <kr_...@us...> - 2003-03-25 23:35:13
|
Update of /cvsroot/htoolkit/gio/src/Graphics/UI/GIO In directory sc8-pr-cvs1:/tmp/cvs-serv16157/src/Graphics/UI/GIO Modified Files: Attributes.hs Log Message: Added newProp function which likely newAttr creates Prop value (instead of Attr). The 'close' operation on widgets are renamed to dismissWidget. Added destroyWidget operation. Index: Attributes.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Attributes.hs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Attributes.hs 30 Jan 2003 23:58:27 -0000 1.4 --- Attributes.hs 25 Mar 2003 23:35:07 -0000 1.5 *************** *** 45,49 **** -- ** Widget , Widget ! , close -- ** Dimensions --- 45,50 ---- -- ** Widget , Widget ! , dismissWidget ! , destroyWidget -- ** Dimensions *************** *** 76,79 **** --- 77,81 ---- , mapAttr , newAttr + , newProp , varAttr , readAttr *************** *** 97,100 **** --- 99,106 ---- = Attr getter setter + newProp :: (w -> IO ()) -> (w -> IO a) -> (w -> a -> IO ()) -> Prop w + newProp action getter setter + = Prop action (\w -> do oldx <- getter w; return (setter w oldx)) + -- | A property of a widget @w@ is an attribute that -- is already associated with a value. Properties are *************** *** 164,200 **** -- | Associate an attribute with a new value into a property. (=:) :: Attr w a -> a -> Prop w ! (=:) (Attr getter setter) x ! = Prop (\w -> setter w x) ! (\w -> do oldx <- getter w; return (setter w oldx)) -- | Apply an update function to an attribute. (~:) :: Attr w a -> (a -> a) -> Prop w ! (~:) (Attr getter setter) f ! = Prop (\w -> do x <- getter w; setter w (f x)) ! (\w -> do oldx <- getter w; return (setter w oldx)) -- | Set the value of an attribute with a function that takes the widget -- itself as an argument. (=::) :: Attr w a -> (w -> a) -> Prop w ! (=::) (Attr getter setter) f ! = Prop (\w -> setter w (f w)) ! (\w -> do oldx <- getter w; return (setter w oldx)) -- | Set the value of an attribute with a function that takes the widget -- itself and the current value of the attribute as arguments. (~::) :: Attr w a -> (w -> a -> a) -> Prop w ! (~::) (Attr getter setter) f ! = Prop (\w -> do x <- getter w; setter w (f w x)) ! (\w -> do oldx <- getter w; return (setter w oldx)) ! {-------------------------------------------------------------------- Classes --------------------------------------------------------------------} ! -- | Every window item is part of the 'Widget' class. The only operation ! -- on widgets is 'close'. class Widget w where -- | Close a widget ! close :: w -> IO () -- | Widgets with dimensions have a width, height and position. Only the --- 170,198 ---- -- | Associate an attribute with a new value into a property. (=:) :: Attr w a -> a -> Prop w ! (=:) (Attr getter setter) x = newProp (\w -> setter w x) getter setter -- | Apply an update function to an attribute. (~:) :: Attr w a -> (a -> a) -> Prop w ! (~:) (Attr getter setter) f = newProp (\w -> do x <- getter w; setter w (f x)) getter setter -- | Set the value of an attribute with a function that takes the widget -- itself as an argument. (=::) :: Attr w a -> (w -> a) -> Prop w ! (=::) (Attr getter setter) f = newProp (\w -> setter w (f w)) getter setter -- | Set the value of an attribute with a function that takes the widget -- itself and the current value of the attribute as arguments. (~::) :: Attr w a -> (w -> a -> a) -> Prop w ! (~::) (Attr getter setter) f = newProp (\w -> do x <- getter w; setter w (f w x)) getter setter {-------------------------------------------------------------------- Classes --------------------------------------------------------------------} ! -- | Every window item is part of the 'Widget' class. The operations ! -- on widgets are 'dismissWidget' and 'destroyWidget'. class Widget w where -- | Close a widget ! dismissWidget :: w -> IO Bool ! destroyWidget :: w -> IO () -- | Widgets with dimensions have a width, height and position. Only the |