ParentContentsIndex
Graphics.UI.GIO.Attributes
Portability portable
Stability provisional
Maintainer ka2_mail@yahoo.com
Contents
Attributes and properties
Generic attribute creators
Common widget classes
Dimensions
HasFont
Drawn
Titled
Able
ToolTip
Accelerated
Positioned
Selection
Icon
Description

Widgets w can have attributes of type a represented by the type Attr w a. An attribute set or read. An example of an attribute is title with type:

 title :: Attr Window String

When an attribute is associated with a value, we call it a property of type Prop w. Properties are constructed with the ('=:') function:

 title =: "hello world"  :: Prop Window

Properties can be set with the set function:

 set win [title =: "hello world"]  :: IO ()

and attributes can be read with the get function:

 get win title  :: IO String

The function get, set and '(=:)' are polymorphic and work for all widgets, but the title attribute just works for windows. Many attributes are defined for multiple widgets and are organised in type classes, for example Deadly and Dimensions.

The ('~:') operator is used to transform an attribute with an update function. For example, the interval on a timer can be doubled with:

 set timer [interval ~: (*2)]
Synopsis
data Attr w a
data Prop w
set1 :: w -> Prop w -> IO ()
set :: w -> [Prop w] -> IO ()
get :: w -> Attr w a -> IO a
with :: w -> [Prop w] -> IO a -> IO a
(=:) :: Attr w a -> a -> Prop w
(~:) :: Attr w a -> (a -> a) -> Prop w
(=::) :: Attr w a -> (w -> a) -> Prop w
(~::) :: Attr w a -> (w -> a -> a) -> Prop w
mapAttr :: (a -> b) -> (a -> b -> a) -> Attr w a -> Attr w b
newAttr :: (w -> IO a) -> (w -> a -> IO ()) -> Attr w a
newStdAttr :: (w -> h) -> (h -> IO a) -> (h -> a -> IO ()) -> Attr w a
newProp :: (w -> IO ()) -> (w -> IO a) -> (w -> a -> IO ()) -> Prop w
varAttr :: (w -> Var a) -> Attr w a
readAttr :: String -> (w -> IO a) -> Attr w a
writeAttr :: String -> (w -> a -> IO ()) -> Attr w a
class Dimensions w
frame :: (Dimensions w) => Attr w Rect
position :: (Dimensions w) => Attr w Point
size :: (Dimensions w) => Attr w Size
width :: (Dimensions w) => Attr w Int
height :: (Dimensions w) => Attr w Int
class HasFont w
font :: (HasFont w) => Attr w Font
class (HasFont w) => Drawn w
bufferMode :: (Drawn w) => Attr w BufferMode
pen :: (Drawn w) => Attr w Pen
color :: (Drawn w) => Attr w Color
bgcolor :: (Drawn w) => Attr w Color
hatch :: (Drawn w) => Attr w HatchStyle
thickness :: (Drawn w) => Attr w Int
capstyle :: (Drawn w) => Attr w CapStyle
linestyle :: (Drawn w) => Attr w LineStyle
joinstyle :: (Drawn w) => Attr w JoinStyle
drawMode :: (Drawn w) => Attr w DrawMode
bkDrawMode :: (Drawn w) => Attr w Bool
class Titled w
title :: (Titled w) => Attr w String
class Able w
enabled :: (Able w) => Attr w Bool
class ToolTip w
tooltip :: (ToolTip w) => Attr w String
class Accelerated w
accel :: (Accelerated w) => Attr w Key
class Positioned w
pos :: (Positioned w) => Attr w Int
class Checked w
checked :: (Checked w) => Attr w Bool
class Countable w
count :: (Countable w) => Attr w Int
class (Countable w) => CommandItems w
items :: (CommandItems w) => Attr w [(String, IO ())]
appendItem :: (CommandItems w) => w -> (String, IO ()) -> IO ()
insertItem :: (CommandItems w) => w -> Int -> (String, IO ()) -> IO ()
removeItem :: (CommandItems w) => w -> Int -> IO ()
removeAllItems :: (CommandItems w) => w -> IO ()
class (Countable w) => SingleSelect w
selected :: (SingleSelect w) => Attr w Int
class (Countable w) => MultiSelect w
selection :: (MultiSelect w) => Attr w [Int]
class RangedSelect w
range :: (RangedSelect w) => Attr w (Int, Int)
selectedPos :: (RangedSelect w) => Attr w Int
class HasIcon w
icon :: (HasIcon w) => Attr w (Maybe Bitmap)
Attributes and properties
data Attr w a
Widgets w can have attributes of type a.
data Prop w
A property of a widget w is an attribute that is already associated with a value. Properties are constructed with the '(=:)' operator.
set1 :: w -> Prop w -> IO ()
set :: w -> [Prop w] -> IO ()
Set properties
get :: w -> Attr w a -> IO a
Get an attribute
with :: w -> [Prop w] -> IO a -> IO a
Set properties just for a certain computation. The previous values are automatically restored on return.
(=:) :: Attr w a -> a -> Prop w
Associate an attribute with a new value into a property.
(~:) :: Attr w a -> (a -> a) -> Prop w
Apply an update function to an attribute.
(=::) :: Attr w a -> (w -> a) -> Prop w
Set the value of an attribute with a function that takes the widget itself as an argument.
(~::) :: Attr w a -> (w -> a -> a) -> Prop w
Set the value of an attribute with a function that takes the widget itself and the current value of the attribute as arguments.
Generic attribute creators
mapAttr :: (a -> b) -> (a -> b -> a) -> Attr w a -> Attr w b
(mapAttr get set attr) maps an attribute of Attr w a to Attr w b where (get :: a -> b) is used when the attribute is requested and (set :: a -> b -> a) is applied to current value when the attribute is set.
newAttr :: (w -> IO a) -> (w -> a -> IO ()) -> Attr w a
Create a new attribute with a specified getter and setter function.
newStdAttr :: (w -> h) -> (h -> IO a) -> (h -> a -> IO ()) -> Attr w a
The newStdAttr function is useful for creation of many standard attributes
newProp :: (w -> IO ()) -> (w -> IO a) -> (w -> a -> IO ()) -> Prop w
varAttr :: (w -> Var a) -> Attr w a
Helper function to implement an attribute that just gets or sets a Var member.
readAttr :: String -> (w -> IO a) -> Attr w a
Define a read-only attribute. Takes the name of the attribute as its first argument.
writeAttr :: String -> (w -> a -> IO ()) -> Attr w a
Define a write-only attribute. Takes the name of the attribute as its first argument.
Common widget classes
Dimensions
class Dimensions w
Widgets with dimensions have a width, height and position. Only the frame method is not defaulted.
Instances
Dimensions Bitmap
Dimensions Label
Dimensions Button
Dimensions Entry
Dimensions Popup
Dimensions ListBox
Dimensions CompoundControl
Dimensions Window
frame :: (Dimensions w) => Attr w Rect
The outer frame of a widget.
position :: (Dimensions w) => Attr w Point
The upper-left corner.
size :: (Dimensions w) => Attr w Size
The size.
width :: (Dimensions w) => Attr w Int
The width.
height :: (Dimensions w) => Attr w Int
The height.
HasFont
class HasFont w
Widgets with a font.
Instances
HasFont CanvasPen
HasFont Label
HasFont Button
HasFont Entry
HasFont CompoundControl
HasFont Window
font :: (HasFont w) => Attr w Font
The font.
Drawn
class (HasFont w) => Drawn w
Instances
Drawn CanvasPen
Drawn CompoundControl
Drawn Window
bufferMode :: (Drawn w) => Attr w BufferMode
The buffering mode. If the window is buffered then all drawing operations are first performed to memory buffer and after that the buffer is copied to the output device.
pen :: (Drawn w) => Attr w Pen
The pen
color :: (Drawn w) => Attr w Color
The (fore ground) color of the widget.
bgcolor :: (Drawn w) => Attr w Color
The back ground color.
hatch :: (Drawn w) => Attr w HatchStyle
The hatch style.
thickness :: (Drawn w) => Attr w Int
The thickness of the drawing pencil.
capstyle :: (Drawn w) => Attr w CapStyle
The cap style.
linestyle :: (Drawn w) => Attr w LineStyle
The line style.
joinstyle :: (Drawn w) => Attr w JoinStyle
The join style.
drawMode :: (Drawn w) => Attr w DrawMode
bkDrawMode :: (Drawn w) => Attr w Bool
Titled
class Titled w
Widgets with a title.
Instances
Titled Label
Titled Button
Titled Entry
Titled CheckBox
Titled RadioBox
Titled GroupBox
Titled NotebookPage
Titled Menu
Titled MenuItem
Titled MenuRadioItem
Titled MenuCheck
Titled ToolButton
Titled ToolCheckButton
Titled ToolRadioButton
Titled ToolDropDownButton
Titled Window
title :: (Titled w) => Attr w String
The title.
Able
class Able w
Widgets that can be enabled or disabled.
Instances
Able Label
Able Button
Able Entry
Able Popup
Able ListBox
Able CheckBox
Able RadioBox
Able CompoundControl
Able Menu
Able MenuItem
Able MenuRadioItem
Able MenuCheck
Able Timer
Able ToolButton
Able ToolCheckButton
Able ToolRadioButton
Able ToolDropDownButton
Able Window
enabled :: (Able w) => Attr w Bool
Enable, or disable, the widget.
ToolTip
class ToolTip w
Widgets that supports tooltips.
Instances
ToolTip Label
ToolTip Button
ToolTip Entry
ToolTip Popup
ToolTip ListBox
ToolTip CheckBox
ToolTip RadioBox
ToolTip ToolButton
ToolTip ToolCheckButton
ToolTip ToolRadioButton
ToolTip ToolDropDownButton
tooltip :: (ToolTip w) => Attr w String
The tip text
Accelerated
class Accelerated w
Widgets that has accelerator key.
Instances
Accelerated MenuItem
Accelerated MenuRadioItem
Accelerated MenuCheck
accel :: (Accelerated w) => Attr w Key
The accelerator. Set the property to (KeyNull) to remove the accelerator key.
Positioned
class Positioned w
Widgets that has specified integer position.
Instances
Positioned NotebookPage
Positioned Menu
Positioned MenuItem
Positioned MenuRadioItem
Positioned MenuCheck
Positioned MenuLine
Positioned ToolButton
Positioned ToolCheckButton
Positioned ToolRadioButton
Positioned ToolDropDownButton
Positioned ToolLine
pos :: (Positioned w) => Attr w Int
The widget position
Selection
class Checked w
Widgets that can be checked.
Instances
Checked CheckBox
Checked RadioBox
Checked MenuRadioItem
Checked MenuCheck
Checked ToolCheckButton
Checked ToolRadioButton
checked :: (Checked w) => Attr w Bool
Check the widget
class Countable w
Countable widgets are these which contains countable finite set of child widgets or items.
Instances
Countable Popup
Countable ListBox
Countable Notebook
Countable Menu
Countable ToolBar
count
:: (Countable w)
=> Attr w Int The attribute is read-only and returns the count of items in the widget.
class (Countable w) => CommandItems w
Widgets that have selectable items, like popup controls.
Instances
CommandItems Popup
CommandItems ListBox
items :: (CommandItems w) => Attr w [(String, IO ())]
appendItem :: (CommandItems w) => w -> (String, IO ()) -> IO ()
insertItem :: (CommandItems w) => w -> Int -> (String, IO ()) -> IO ()
removeItem :: (CommandItems w) => w -> Int -> IO ()
removeAllItems :: (CommandItems w) => w -> IO ()
class (Countable w) => SingleSelect w
Widgets that have a single selection (like popup control).
Instances
SingleSelect Popup
SingleSelect ListBox
SingleSelect Notebook
selected :: (SingleSelect w) => Attr w Int
class (Countable w) => MultiSelect w
Widgets with a multiple selection (like multi selection list box).
Instances
MultiSelect ListBox
selection :: (MultiSelect w) => Attr w [Int]
class RangedSelect w
Widgets that selects integer position inside the specified range.
Instances
RangedSelect Slider
RangedSelect ProgressBar
range :: (RangedSelect w) => Attr w (Int, Int)
The selection range
selectedPos :: (RangedSelect w) => Attr w Int
The selected position
Icon
class HasIcon w
Widgets which displays an icon.
Instances
HasIcon NotebookPage
HasIcon MenuItem
HasIcon ToolButton
HasIcon ToolCheckButton
HasIcon ToolRadioButton
HasIcon ToolDropDownButton
icon :: (HasIcon w) => Attr w (Maybe Bitmap)
Produced by Haddock version 0.4