|
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 |
|
|
|
|
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 | |
|
|
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 | |
|
|
font :: (HasFont w) => Attr w Font |
The font. |
|
Drawn |
|
class (HasFont w) => Drawn w |
|
|
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 | |
|
|
title :: (Titled w) => Attr w String |
The title. |
|
Able |
|
class Able w |
Widgets that can be enabled or disabled. | | Instances | |
|
|
enabled :: (Able w) => Attr w Bool |
Enable, or disable, the widget. |
|
ToolTip |
|
class ToolTip w |
Widgets that supports tooltips. | | Instances | |
|
|
tooltip :: (ToolTip w) => Attr w String |
The tip text |
|
Accelerated |
|
class Accelerated w |
Widgets that has accelerator key. | | Instances | |
|
|
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 | |
|
|
pos :: (Positioned w) => Attr w Int |
The widget position |
|
Selection |
|
class Checked w |
Widgets that can be checked. | | Instances | |
|
|
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 | |
|
|
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 | |
|
|
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 | |
|
|
selected :: (SingleSelect w) => Attr w Int |
|
class (Countable w) => MultiSelect w |
Widgets with a multiple selection (like multi selection list box). | | Instances | |
|
|
selection :: (MultiSelect w) => Attr w [Int] |
|
class RangedSelect w |
Widgets that selects integer position inside the specified range. | | Instances | |
|
|
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 | |
|
|
icon :: (HasIcon w) => Attr w (Maybe Bitmap) |
|
Produced by Haddock version 0.4 |