Module UI

Interface for ui descriptions

Author: Christof Kluss

Version: September 2008

Summary of exported operations:

showWidgetKind :: WidgetKind a b c -> String   
addStyle :: Widget a b c -> StyleClass -> Widget a b c   
addStyles :: Widget a b c -> [StyleClass] -> Widget a b c   
setStyles :: Widget a b c -> [StyleClass] -> Widget a b c   
addHandler :: Widget a b c -> Handler b c -> Widget a b c   
addHandlers :: Widget a b c -> [Handler b c] -> Widget a b c   
setHandlers :: Widget a b c -> [Handler b c] -> Widget a b c   
setRef :: Widget a b c -> Ref a -> Widget a b c   
getRef :: Widget a b c -> (Ref a,Widget a b c)   
runUI :: String -> Widget () (UIEnv -> IO ()) () -> IO ()   
Run a Widget in a new window.
exitUI :: UIEnv -> IO ()   
An event handler for terminating the GUI.
getValue :: Ref () -> UIEnv -> IO String   
Gets the String value of a variable in an UI.
setValue :: Ref () -> String -> UIEnv -> IO ()   
Sets the String value of a variable in an UI.
updateValue :: (String -> String) -> Ref () -> UIEnv -> IO ()   
Updates the (String) value of a variable w.r.t.
appendValue :: Ref () -> String -> UIEnv -> IO ()   
Appends a String value to the contents of a widget.
changeStyles :: Ref () -> [StyleClass] -> UIEnv -> IO ()   
Changes the style of a widget
setHandler :: Ref () -> Event -> (UIEnv -> IO ()) -> UIEnv -> IO ()   
Sets a new Handler to a Widget referred by the first argument.
setDisabled :: Ref () -> Bool -> UIEnv -> IO ()   
Sets the state of a widget to disabled (inactive) or active (inactive widgets do not accept any events)
addCanvas :: Ref () -> [CanvasItem] -> UIEnv -> IO ()   
Adds a list of canvas items to a canvas referred by the first argument.
showPopup :: String -> Widget () (UIEnv -> IO ()) () -> UIEnv -> IO ()   
Runs a Widget in a new window.
showMessage :: String -> UIEnv -> IO ()   
Shows a String Message in a new window.
colS :: [StyleClass] -> [Widget a b c] -> Widget a b c   
Vertical alignment of widgets.
col :: [Widget a b c] -> Widget a b c   
rowS :: [StyleClass] -> [Widget a b c] -> Widget a b c   
Horizontal alignment of widgets.
row :: [Widget a b c] -> Widget a b c   
matrixS :: [StyleClass] -> [[Widget a b c]] -> Widget a b c   
A 2-dimensional (matrix) alignment of widgets
matrix :: [[Widget a b c]] -> Widget a b c   
entry :: Ref a -> String -> Widget a b c   
An entry widget for entering single lines
entryS :: [StyleClass] -> Ref a -> String -> Widget a b c   
label :: String -> Widget a b c   
A label for showing a text
labelS :: [StyleClass] -> String -> Widget a b c   
button :: a -> String -> Widget b a c   
buttonS :: [StyleClass] -> a -> String -> Widget b a c   
simpleButton :: Ref a -> String -> Widget a b c   
A button without handler, but reference
simpleButtonS :: [StyleClass] -> Ref a -> String -> Widget a b c   
checkButton :: Ref a -> b -> String -> Bool -> Widget a b c   
A check button: it has value "0" if it is unchecked and value "1" if it is checked
checkButtonS :: [StyleClass] -> Ref a -> b -> String -> Bool -> Widget a b c   
simpleCheckButton :: Ref a -> String -> Bool -> Widget a b c   
simpleCheckButtonS :: [StyleClass] -> Ref a -> String -> Bool -> Widget a b c   
canvas :: Ref a -> Int -> Int -> Widget a b c   
canvasS :: [StyleClass] -> Ref a -> Int -> Int -> Widget a b c   
textEdit :: Ref a -> String -> Int -> Int -> Widget a b c   
textEditS :: [StyleClass] -> Ref a -> String -> Int -> Int -> Widget a b c   
scale :: Ref a -> b -> Int -> Int -> Widget a b c   
A scale widget to input values by a slider
scaleS :: [StyleClass] -> Ref a -> b -> Int -> Int -> Widget a b c   
message :: Ref a -> Widget a b c   
A message for showing simple string values
messageS :: [StyleClass] -> Ref a -> Widget a b c   
menuBar :: [Widget a b c] -> Widget a b c   
A menubar contains a list of menus
menuBarS :: [StyleClass] -> [Widget a b c] -> Widget a b c   
menu :: String -> [Widget a b c] -> Widget a b c   
A button with a pull-down menu for a menubar
menuS :: [StyleClass] -> String -> [Widget a b c] -> Widget a b c   
menuSeparator :: Widget a b c   
A separator between menu entries
menuSeparatorS :: [StyleClass] -> Widget a b c   
menuItem :: a -> String -> Widget b a c   
A button with an associated command and a label string
menuItemS :: [StyleClass] -> a -> String -> Widget b a c   
listBox :: Int -> [String] -> Ref a -> b -> Widget a b c   
A widget containing a list of items for selection
listBoxS :: [StyleClass] -> Int -> [String] -> Ref a -> b -> Widget a b c   
selection :: Ref a -> [String] -> Widget a b c   
A selection button with a reference and a list of name/value pairs.
selectionInitial :: Ref a -> [String] -> Int -> Widget a b c   
A selection button with a reference, a list of name/value pairs, and a preselected item in this list.
selectionInitialS :: [StyleClass] -> Ref a -> [String] -> Int -> Widget a b c   
radio_main :: Ref a -> String -> Widget a b c   
A main button of a radio (initially "on") with a reference and a value.
radio_other :: Ref a -> String -> Widget a b c   
A further button of a radio (initially "off") with a reference (identical to the main button of this radio) and a value.
showBorderStyle :: BorderStyle -> String   
showColor :: Color -> String   
Converts a style value into its textual representation.
showPos :: Position -> String   

Exported datatypes:


Command

Constructors:

  • Cmd :: a -> Command a b
  • SpicyDoc :: b -> Command a b

Ref

The data type of references to widgets in a UI window.

Constructors:

  • Ref :: a -> Ref a

Handler

Constructors:


Widget

The generic type of a widget in an UI.

Constructors:


Event

The data type of possible events on which handlers can react.

Constructors:

  • DefaultEvent :: Event
  • FocusOut :: Event
  • FocusIn :: Event
  • MouseButton1 :: Event
  • MouseButton2 :: Event
  • MouseButton3 :: Event
  • KeyPress :: Event
  • Return :: Event
  • Change :: Event
  • Click :: Event
  • DoubleClick :: Event

WidgetKind

Constructors:

  • Col :: WidgetKind a b c
  • Row :: WidgetKind a b c
  • Matrix :: [[Widget a b c]] -> WidgetKind a b c
  • Label :: WidgetKind a b c
  • Button :: WidgetKind a b c
  • Entry :: WidgetKind a b c
  • TextEdit :: Int -> Int -> WidgetKind a b c
  • Scale :: Int -> Int -> WidgetKind a b c
  • CheckButton :: Bool -> WidgetKind a b c
  • Menu :: WidgetKind a b c
  • MenuSeparator :: WidgetKind a b c
  • MenuBar :: WidgetKind a b c
  • MenuItem :: WidgetKind a b c
  • Canvas :: Int -> Int -> WidgetKind a b c
  • ListBox :: Int -> [String] -> Int -> WidgetKind a b c
  • ListBoxItem :: String -> Bool -> WidgetKind a b c
  • Name :: String -> WidgetKind a b c
  • Link :: WidgetKind a b c
  • RadioButton :: Bool -> WidgetKind a b c

CanvasItem

The data type of items in a canvas.

Constructors:

  • CLine :: [(Int,Int)] -> String -> CanvasItem
  • CPolygon :: [(Int,Int)] -> String -> CanvasItem
  • CRectangle :: (Int,Int) -> (Int,Int) -> String -> CanvasItem
  • COval :: (Int,Int) -> (Int,Int) -> String -> CanvasItem
  • CText :: (Int,Int) -> String -> String -> CanvasItem

StyleClass

Constructors:

  • Class :: [Style] -> StyleClass

Position

Constructors:

  • Center :: Position
  • Left :: Position
  • Right :: Position
  • Top :: Position
  • Bottom :: Position

Direction

Constructors:

  • X :: Direction
  • Y :: Direction
  • Both :: Direction

Style

The data type of possible styles.

Constructors:

  • Align :: Position -> Style
  • TextAlign :: Position -> Style
  • TextColor :: Color -> Style
  • Fill :: Direction -> Style
  • Height :: Int -> Style
  • Width :: Int -> Style
  • Active :: Bool -> Style
  • Fg :: Color -> Style
  • Bg :: Color -> Style
  • Font :: FontStyle -> Style
  • Border :: BorderStyle -> Style
  • Display :: Bool -> Style
  • NameValue :: String -> String -> Style

BorderStyle

Constructors:

  • Dotted :: BorderStyle
  • Dashed :: BorderStyle
  • Solid :: BorderStyle

FontStyle

Constructors:

  • Bold :: FontStyle
  • Italic :: FontStyle
  • Underline :: FontStyle

Color

The data type of possible colors.

Constructors:

  • Black :: Color
  • Blue :: Color
  • Brown :: Color
  • Cyan :: Color
  • Gold :: Color
  • Gray :: Color
  • Green :: Color
  • Magenta :: Color
  • Navy :: Color
  • Orange :: Color
  • Pink :: Color
  • Purple :: Color
  • Red :: Color
  • Tomato :: Color
  • Turquoise :: Color
  • Violet :: Color
  • White :: Color
  • Yellow :: Color
  • Default :: Color

UIEnv

Constructors:


Exported operations:

showWidgetKind :: WidgetKind a b c -> String   

Further infos:
  • solution complete, i.e., able to compute all solutions

addStyle :: Widget a b c -> StyleClass -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

addStyles :: Widget a b c -> [StyleClass] -> Widget a b c   

Further infos:
  • defined as left-associative infix operator with precedence 0
  • solution complete, i.e., able to compute all solutions

setStyles :: Widget a b c -> [StyleClass] -> Widget a b c   

Further infos:
  • defined as left-associative infix operator with precedence 0
  • solution complete, i.e., able to compute all solutions

addHandler :: Widget a b c -> Handler b c -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

addHandlers :: Widget a b c -> [Handler b c] -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

setHandlers :: Widget a b c -> [Handler b c] -> Widget a b c   

Further infos:
  • defined as left-associative infix operator with precedence 0
  • solution complete, i.e., able to compute all solutions

setRef :: Widget a b c -> Ref a -> Widget a b c   

Further infos:
  • defined as left-associative infix operator with precedence 0
  • solution complete, i.e., able to compute all solutions

getRef :: Widget a b c -> (Ref a,Widget a b c)   

runUI :: String -> Widget () (UIEnv -> IO ()) () -> IO ()   

Run a Widget in a new window.

exitUI :: UIEnv -> IO ()   

An event handler for terminating the GUI.

getValue :: Ref () -> UIEnv -> IO String   

Gets the String value of a variable in an UI.

setValue :: Ref () -> String -> UIEnv -> IO ()   

Sets the String value of a variable in an UI.

updateValue :: (String -> String) -> Ref () -> UIEnv -> IO ()   

Updates the (String) value of a variable w.r.t. to an update function.

appendValue :: Ref () -> String -> UIEnv -> IO ()   

Appends a String value to the contents of a widget.

changeStyles :: Ref () -> [StyleClass] -> UIEnv -> IO ()   

Changes the style of a widget

setHandler :: Ref () -> Event -> (UIEnv -> IO ()) -> UIEnv -> IO ()   

Sets a new Handler to a Widget referred by the first argument. An existing Handler for the same event type is overridden

setDisabled :: Ref () -> Bool -> UIEnv -> IO ()   

Sets the state of a widget to disabled (inactive) or active (inactive widgets do not accept any events)

addCanvas :: Ref () -> [CanvasItem] -> UIEnv -> IO ()   

Adds a list of canvas items to a canvas referred by the first argument.

showPopup :: String -> Widget () (UIEnv -> IO ()) () -> UIEnv -> IO ()   

Runs a Widget in a new window.

showMessage :: String -> UIEnv -> IO ()   

Shows a String Message in a new window.

colS :: [StyleClass] -> [Widget a b c] -> Widget a b c   

Vertical alignment of widgets.

Further infos:
  • solution complete, i.e., able to compute all solutions

col :: [Widget a b c] -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

rowS :: [StyleClass] -> [Widget a b c] -> Widget a b c   

Horizontal alignment of widgets.

Further infos:
  • solution complete, i.e., able to compute all solutions

row :: [Widget a b c] -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

matrixS :: [StyleClass] -> [[Widget a b c]] -> Widget a b c   

A 2-dimensional (matrix) alignment of widgets

Further infos:
  • solution complete, i.e., able to compute all solutions

matrix :: [[Widget a b c]] -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

entry :: Ref a -> String -> Widget a b c   

An entry widget for entering single lines

Further infos:
  • solution complete, i.e., able to compute all solutions

entryS :: [StyleClass] -> Ref a -> String -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

label :: String -> Widget a b c   

A label for showing a text

Further infos:
  • solution complete, i.e., able to compute all solutions

labelS :: [StyleClass] -> String -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

button :: a -> String -> Widget b a c   

Further infos:
  • solution complete, i.e., able to compute all solutions

buttonS :: [StyleClass] -> a -> String -> Widget b a c   

Further infos:
  • solution complete, i.e., able to compute all solutions

simpleButton :: Ref a -> String -> Widget a b c   

A button without handler, but reference

Further infos:
  • solution complete, i.e., able to compute all solutions

simpleButtonS :: [StyleClass] -> Ref a -> String -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

checkButton :: Ref a -> b -> String -> Bool -> Widget a b c   

A check button: it has value "0" if it is unchecked and value "1" if it is checked

Further infos:
  • solution complete, i.e., able to compute all solutions

checkButtonS :: [StyleClass] -> Ref a -> b -> String -> Bool -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

simpleCheckButton :: Ref a -> String -> Bool -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

simpleCheckButtonS :: [StyleClass] -> Ref a -> String -> Bool -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

canvas :: Ref a -> Int -> Int -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

canvasS :: [StyleClass] -> Ref a -> Int -> Int -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

textEdit :: Ref a -> String -> Int -> Int -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

textEditS :: [StyleClass] -> Ref a -> String -> Int -> Int -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

scale :: Ref a -> b -> Int -> Int -> Widget a b c   

A scale widget to input values by a slider

Further infos:
  • solution complete, i.e., able to compute all solutions

scaleS :: [StyleClass] -> Ref a -> b -> Int -> Int -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

message :: Ref a -> Widget a b c   

A message for showing simple string values

Further infos:
  • solution complete, i.e., able to compute all solutions

messageS :: [StyleClass] -> Ref a -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

listBox :: Int -> [String] -> Ref a -> b -> Widget a b c   

A widget containing a list of items for selection

listBoxS :: [StyleClass] -> Int -> [String] -> Ref a -> b -> Widget a b c   

selection :: Ref a -> [String] -> Widget a b c   

A selection button with a reference and a list of name/value pairs. The names are shown in the selection and the value is returned for the selected name.

selectionInitial :: Ref a -> [String] -> Int -> Widget a b c   

A selection button with a reference, a list of name/value pairs, and a preselected item in this list. The names are shown in the selection and the value is returned for the selected name.

Further infos:
  • solution complete, i.e., able to compute all solutions

selectionInitialS :: [StyleClass] -> Ref a -> [String] -> Int -> Widget a b c   

Further infos:
  • solution complete, i.e., able to compute all solutions

radio_main :: Ref a -> String -> Widget a b c   

A main button of a radio (initially "on") with a reference and a value. The value is returned of this button is on. A complete radio button suite always consists of a main button (radiomain) and some further buttons (radioothers) with the same reference. Initially, the main button is selected (or nothing is selected if one uses radiomainoff instead of radio_main). The user can select another button but always at most one button of the radio can be selected. The value corresponding to the selected button is returned in the environment for this radio reference.

Further infos:
  • solution complete, i.e., able to compute all solutions

radio_other :: Ref a -> String -> Widget a b c   

A further button of a radio (initially "off") with a reference (identical to the main button of this radio) and a value. The value is returned of this button is on.

Further infos:
  • solution complete, i.e., able to compute all solutions

showBorderStyle :: BorderStyle -> String   

Further infos:
  • solution complete, i.e., able to compute all solutions

showColor :: Color -> String   

Converts a style value into its textual representation.

Further infos:
  • solution complete, i.e., able to compute all solutions

showPos :: Position -> String   

Further infos:
  • solution complete, i.e., able to compute all solutions