16. StdTimer

The timer is a device with a specified event handler, which is called at a fixed time interval.

data Timer t ls ps = Timer TimerInterval (t ls ps) [TimerAttribute ls ps]

type TimerInterval = Int

data TimerAttribute ls ps                                       -- Default:
        = TimerFunction         (TimerFunction ls ps)           -- \_ x->x
        | TimerId               Id                              -- no Id
        | TimerInit             (GUIFun ls ps)                  -- no actions after opening timer
        | TimerSelectState      SelectState                     -- timer Able

type TimerFunction ls ps = NrOfIntervals -> GUIFun ls ps
type NrOfIntervals = Int

class Timers tdef where
        openTimer :: ls -> tdef ls ps -> ps -> GUI ps ps

instance TimerElements t => Timers (Timer t)

closeTimer :: Id -> GUI ps ()

getTimers :: GUI ps [Id]

enableTimer :: Id -> GUI ps ()
disableTimer :: Id -> GUI ps ()
getTimerSelectState :: Id -> GUI ps (Maybe SelectState)

setTimerInterval :: Id -> TimerInterval -> GUI ps ()
getTimerInterval :: Id -> GUI ps (Maybe TimerInterval)

Timers can be created by Timers class. This allows the user to define his/her own timer types instead of built-in types

closeTimer

closes the timer with the specified Id

getTimers

returns the list of Ids of all existing timers for the current process.

enableTimer

enables the timer with the specified Id

disableTimer

disables the timer with the specified Id

getTimerSelectState

returns the current SelectState for timer with the specified Id. SelectState can be changed by enableTimer and disableTimer functions.

setTimerInterval

sets the timer interval

getTimerInterval

returns the current timer interval