Graphics Libraries (HGL package)Source codeContentsIndex
Graphics.HGL.Window
Portabilitynon-portable (requires concurrency)
Stabilityprovisional
Maintainerlibraries@haskell.org
Contents
Windows
Drawing in a window
Events in a window
Timer ticks
Description
Windows in a simple graphics library.
Synopsis
data Window
type Title = String
data RedrawMode
= DoubleBuffered
| Unbuffered
openWindowEx :: Title -> Maybe Point -> Size -> RedrawMode -> Maybe Time -> IO Window
getWindowRect :: Window -> IO (Point, Size)
closeWindow :: Window -> IO ()
setGraphic :: Window -> Graphic -> IO ()
getGraphic :: Window -> IO Graphic
modGraphic :: Window -> (Graphic -> Graphic) -> IO ()
directDraw :: Window -> Graphic -> IO ()
data Event
= Char {
char :: Char
}
| Key {
keysym :: Key
isDown :: Bool
}
| Button {
pt :: Point
isLeft :: Bool
isDown :: Bool
}
| MouseMove {
pt :: Point
}
| Resize
| Closed
getWindowEvent :: Window -> IO Event
maybeGetWindowEvent :: Window -> IO (Maybe Event)
getWindowTick :: Window -> IO ()
getTime :: IO Integer
Windows
data Window
type Title = String
Title of a window.
data RedrawMode
How to draw in a window.
Constructors
DoubleBuffereduse a double buffer to reduce flicker. You should probably use this for animations.
Unbuffereddraw directly to the window. This runs slightly faster but is more prone to flicker.
openWindowEx
:: Titletitle of the window
-> Maybe Pointthe optional initial position of a window
-> Sizeinitial size of the window
-> RedrawModehow to display a graphic on the window
-> Maybe Timethe time between ticks (in milliseconds) of an optional timer associated with the window
-> IO Window
General window creation.
getWindowRect :: Window -> IO (Point, Size)
The position of the top left corner of the window on the screen, and the size of the window.
closeWindow :: Window -> IO ()
Close the window.
Drawing in a window
setGraphic :: Window -> Graphic -> IO ()
Set the current drawing in a window.
getGraphic :: Window -> IO Graphic
Get the current drawing in a window.
modGraphic :: Window -> (Graphic -> Graphic) -> IO ()
Update the drawing for a window. Note that this does not force a redraw.
directDraw :: Window -> Graphic -> IO ()
Events in a window
data Event

A user interface event.

Notes:

  • Programmers should assume that the Event datatype will be extended in the not-too-distant future and that individual events may change slightly. As a minimum, you should add a "match anything" alternative to any function which pattern matches against Events.
  • X11 systems typically have three button mice. Button 1 is used as the left button, button 3 as the right button and button 2 (the middle button) is ignored.
Constructors
Chara properly translated character, sent after a key press.
char :: Charthe character represented by a key combination
Keyoccurs when a key was pressed or released.
keysym :: Keyrepresentation of the keyboard keys pressed
isDown :: Boolif True, the key was pressed; otherwise it was released
Buttonoccurs when a mouse button is pressed or released.
pt :: Pointthe position of the mouse cursor
isLeft :: Boolif True, it was the left button
isDown :: Boolif True, the button was pressed; otherwise it was released
MouseMoveoccurs when the mouse is moved inside the window.
pt :: Pointthe position of the mouse cursor after the movement
Resizeoccurs when the window is resized.
Closedoccurs when the window is closed.
show/hide Instances
getWindowEvent :: Window -> IO Event
Wait for the next event on the given window.
maybeGetWindowEvent :: Window -> IO (Maybe Event)
Check for a pending event on the given window.
Timer ticks
Timers that tick at regular intervals are set up by openWindowEx.
getWindowTick :: Window -> IO ()
Wait for the next tick event from the timer on the given window.
getTime :: IO Integer
Time in milliseconds since some arbitrary epoch.
Produced by Haddock version 0.8