ContentsIndex
Graphics.UI.Port
Portability portable
Stability provisional
Maintainer ka2_mail@yahoo.com
Contents
Re-exports
Windows
Controls
Drawing
Timers
Process
Fundamental
Geometry
Points
Sizes
Rectangles
Render
Colors
Bitmaps
Canvas
Fonts
Events
Modifiers
Mouse events
Keyboard events
Document interface
PositionType
Primitive Handles
Marshalling to C
Configuration
Description
The main interface of Port. Re-exports functionality from other modules.
Synopsis
module Graphics.UI.Port.Menu
module Graphics.UI.Port.Window
module Graphics.UI.Port.CommonDialogs
module Graphics.UI.Port.Message
module Graphics.UI.Port.ToolBar
module Graphics.UI.Port.Controls
module Graphics.UI.Port.Canvas
module Graphics.UI.Port.Font
module Graphics.UI.Port.Bitmap
module Graphics.UI.Port.Timer
module Graphics.UI.Port.Process
module Graphics.UI.Port.Handlers
data Point = Point {
px :: !Int
py :: !Int
}
pt :: Int -> Int -> Point
pointMove :: Size -> Point -> Point
pointAdd :: Point -> Point -> Point
pointSub :: Point -> Point -> Point
pointScale :: Int -> Point -> Point
data Size = Size {
sw :: !Int
sh :: !Int
}
sz :: Int -> Int -> Size
sizeEncloses :: Size -> Size -> Bool
maxSize :: Size -> Size -> Size
addh :: Size -> Size -> Size
addv :: Size -> Size -> Size
addSize :: Size -> Size -> Size
sizeDistance :: Point -> Point -> Size
data Rect = Rect {
left :: !Int
top :: !Int
right :: !Int
bottom :: !Int
}
topLeft :: Rect -> Point
topRight :: Rect -> Point
bottomLeft :: Rect -> Point
bottomRight :: Rect -> Point
rect :: Point -> Point -> Rect
rectAt :: Point -> Size -> Rect
rectSize :: Rect -> Size
rectOfSize :: Size -> Rect
rectIsEmpty :: Rect -> Bool
pointInRect :: Point -> Rect -> Bool
rectMove :: Size -> Rect -> Rect
rectMoveTo :: Point -> Rect -> Rect
pointToRect :: Point -> Rect
centralPoint :: Rect -> Point
centralRect :: Rect -> Size -> Rect
rectStretchTo :: Size -> Rect -> Rect
disjointRects :: Rect -> Rect -> Bool
rectsDiff :: Rect -> Rect -> [Rect]
rectUnion :: Rect -> Rect -> Rect
rectSect :: Rect -> Rect -> Rect
module Graphics.UI.Port.Colors
data Bitmap
data Codec = Codec {
codecName :: !String
codecDescr :: !String
codecMime :: !String
codecExtensions :: ![String]
codecIsReadable :: !Bool
codecIsWritable :: !Bool
}
data DrawMode
= DrawCopy
| DrawInvert
| DrawXor
data BufferMode
= Buffered
| UnBuffered
data JoinStyle
= JoinBevel
| JoinMiter
| JoinRound
data CapStyle
= CapRound
| CapSquare
| CapFlat
data LineStyle
= LineSolid
| LineDash
| LineDot
| LineDashDot
| LineDashDotDot
| LineCustomStyle [Word8]
data HatchStyle
= HatchSolid
| HatchBDiagonal
| HatchFDiagonal
| HatchCross
| HatchDiagCross
| HatchHorizontal
| HatchVertical
| HatchPattern Bitmap
data Font
fontDef :: Font -> FontDef
data FontDef = FontDef {
fontName :: !FontName
fontSize :: !FontSize
fontWeight :: !FontWeight
fontStyle :: !FontStyle
fontUnderline :: !Bool
fontStrikeOut :: !Bool
}
type FontName = String
type FontSize = Int
type FontWeight = Int
data FontStyle
= Roman
| Italic
| Oblique
fontMinWeight :: Int
fontMaxWeight :: Int
fontNormalWeight :: Int
fontBoldWeight :: Int
data FontMetrics = FontMetrics {
fontAscent :: !Int
fontDescent :: !Int
fontLeading :: !Int
fontMaxWidth :: !Int
}
fontLineHeight :: FontMetrics -> Int
data Modifiers = Modifiers {
shiftDown :: !Bool
controlDown :: !Bool
altDown :: !Bool
}
noneDown :: Modifiers -> Bool
justShift :: Modifiers
justAlt :: Modifiers
justControl :: Modifiers
noModifiers :: Modifiers
data MouseEvent
= MouseMove !Point !Modifiers
| MouseRightDown !Point !Modifiers
| MouseRightUp !Point !Modifiers
| MouseLeftDown !Point !Modifiers
| MouseLeftUp !Point !Modifiers
| MouseDoubleClick !Point !Modifiers
| MouseDrag !Point !Modifiers
mousePos :: MouseEvent -> Point
mouseModifiers :: MouseEvent -> Modifiers
data KeyboardEvent
= KeyDown !Key !IsRepeatKey
| KeyUp !Key
| KeyLost !Key
data Key
= KeyBegin Modifiers
| KeyClear Modifiers
| KeyDelete Modifiers
| KeyEnd Modifiers
| KeyArrowDown Modifiers
| KeyArrowLeft Modifiers
| KeyArrowRight Modifiers
| KeyArrowUp Modifiers
| KeyPageDown Modifiers
| KeyPageUp Modifiers
| KeyEscape Modifiers
| KeyEnter Modifiers
| KeyTab Modifiers
| KeyBackSpace Modifiers
| KeyF1 Modifiers
| KeyF2 Modifiers
| KeyF3 Modifiers
| KeyF4 Modifiers
| KeyF5 Modifiers
| KeyF6 Modifiers
| KeyF7 Modifiers
| KeyF8 Modifiers
| KeyF9 Modifiers
| KeyF10 Modifiers
| KeyF11 Modifiers
| KeyF12 Modifiers
| KeyF13 Modifiers
| KeyF14 Modifiers
| KeyF15 Modifiers
| KeyHelp Modifiers
| KeyChar !Char
| KeyAltChar !Char
| KeyNull
keyModifiers :: Key -> Modifiers
keyboardKey :: KeyboardEvent -> Key
keyboardRepeat :: KeyboardEvent -> Bool
data DocumentInterface
= NDI
| SDI
| MDI
data PositionType
= PosLeft
| PosTop
| PosRight
| PosBottom
type WindowHandle = Ptr WH
type CanvasHandle = Ptr CH
type MenuHandle = Ptr MH
type FontHandle = Ptr FH
type BitmapHandle = Ptr BH
type TimerHandle = Ptr TH
type ToolHandle = Ptr TLH
nullHandle :: Ptr a
toCDrawMode :: DrawMode -> CInt
toCBufferMode :: BufferMode -> CBool
toCJoinStyle :: JoinStyle -> CInt
toCCapStyle :: CapStyle -> CInt
withCLineStyle :: LineStyle -> (CInt -> CInt -> Ptr CUChar -> IO a) -> IO a
withCHatchStyle :: HatchStyle -> (CInt -> BitmapHandle -> IO a) -> IO a
withCBitmap :: Bitmap -> (BitmapHandle -> IO a) -> IO a
fromCBitmap :: BitmapHandle -> IO Bitmap
withCFont :: Font -> (FontHandle -> IO a) -> IO a
fromCFont :: FontDef -> FontHandle -> IO Font
withCFontDef :: FontDef -> (CString -> CInt -> CInt -> CInt -> IO a) -> IO a
withCFontDefResult :: (Ptr CString -> Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CBool -> Ptr CBool -> IO ()) -> IO FontDef
fromCFontDef :: CString -> CInt -> CInt -> CInt -> CBool -> CBool -> IO FontDef
fromCStyle :: CInt -> (FontStyle, Bool, Bool)
fromCWeight :: CInt -> Int
withCFontMetricsResult :: (Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()) -> IO FontMetrics
fromCFontMetrics :: CInt -> CInt -> CInt -> CInt -> FontMetrics
withCPoint :: Point -> (CInt -> CInt -> IO a) -> IO a
withCPointResult :: (Ptr CInt -> IO ()) -> IO Point
fromCPoint :: CInt -> CInt -> Point
withCSize :: Size -> (CInt -> CInt -> IO a) -> IO a
withCSizeResult :: (Ptr CInt -> IO ()) -> IO Size
fromCSize :: CInt -> CInt -> Size
withCRect :: Rect -> (CInt -> CInt -> CInt -> CInt -> IO a) -> IO a
withCRectResult :: (Ptr CInt -> IO ()) -> IO Rect
fromCRect :: CInt -> CInt -> CInt -> CInt -> Rect
fromCModifiers :: CWord -> Modifiers
toCModifiers :: Modifiers -> CWord
fromCKey :: CInt -> CWord -> Key
toCKey :: Key -> (CInt, CWord)
fromCMouseEvent :: CInt -> CInt -> CInt -> CWord -> MouseEvent
fromCKeyboardEvent :: CInt -> CInt -> CWord -> KeyboardEvent
toCDocumentInterface :: DocumentInterface -> CInt
toCPositionType :: PositionType -> CInt
fromCPositionType :: CInt -> PositionType
fromCInt :: CInt -> Int
toCInt :: Int -> CInt
type CWord = CUInt
fromCWord :: CWord -> Int
toCWord :: Int -> CWord
type CBool = CInt
fromCBool :: CBool -> Bool
toCBool :: Bool -> CBool
fromCChar :: CChar -> Char
toCChar :: Char -> CChar
withCStrings :: [String] -> (Ptr CChar -> IO a) -> IO a
peekCStrings :: Ptr CChar -> IO [String]
resultCString :: IO CString -> IO String
resultCStrings :: IO (Ptr CChar) -> IO [String]
module Graphics.UI.Port.ConfigKey
Re-exports
Windows
module Graphics.UI.Port.Menu
module Graphics.UI.Port.Window
module Graphics.UI.Port.CommonDialogs
module Graphics.UI.Port.Message
module Graphics.UI.Port.ToolBar
Controls
module Graphics.UI.Port.Controls
Drawing
module Graphics.UI.Port.Canvas
module Graphics.UI.Port.Font
module Graphics.UI.Port.Bitmap
Timers
module Graphics.UI.Port.Timer
Process
module Graphics.UI.Port.Process
Fundamental
module Graphics.UI.Port.Handlers
Geometry
Points
data Point
A point has an x and y coordinate. Coordinates are normally relative to the upper-left corner of their view frame, where a positive x goes to the right and a positive y to the bottom of the view.
Constructors
Point
px :: !Intx component of a point.
py :: !Inty component of a point.
Instances
Eq Point
Show Point
Read Point
pt :: Int -> Int -> Point
Short function to construct a point.
pointMove :: Size -> Point -> Point
pointAdd :: Point -> Point -> Point
pointSub :: Point -> Point -> Point
pointScale :: Int -> Point -> Point
Sizes
data Size
A Size has a width and height.
Constructors
Size
sw :: !Intthe width of a size
sh :: !Intthe height of a size
Instances
Eq Size
Show Size
Read Size
sz :: Int -> Int -> Size
Short function to construct a size
sizeEncloses :: Size -> Size -> Bool
maxSize :: Size -> Size -> Size
addh :: Size -> Size -> Size
addv :: Size -> Size -> Size
addSize :: Size -> Size -> Size
sizeDistance :: Point -> Point -> Size
Rectangles
data Rect
A rectangle is defined by four points -- the left x coordinate, the top y coordinate, the right x coordinate and the bottom y coordinate. Pixels lie between the cooridinates. This means that a rectangle where all coordinates are the same, designates an empty area (and not a single pixel). The pixel width of a rectangle is therefore simply the difference between the right and left, or bottom and top coordinate.
Constructors
Rect
left :: !Int
top :: !Int
right :: !Int
bottom :: !Int
Instances
Eq Rect
Show Rect
topLeft :: Rect -> Point
The top left corner of the rectangle
topRight :: Rect -> Point
The top right corner of the rectangle
bottomLeft :: Rect -> Point
The bottom left corner of the rectangle
bottomRight :: Rect -> Point
The bottom right corner of the rectangle
rect :: Point -> Point -> Rect
Construct a (positive) rectangle between two (arbitraty) points.
rectAt :: Point -> Size -> Rect
Create a rectangle at a certain (upper-left) point with a certain size.
rectSize :: Rect -> Size
Get the size of a rectangle.
rectOfSize :: Size -> Rect
Create a rectangle of a certain size with the upper-left corner at (pt 0 0).
rectIsEmpty :: Rect -> Bool
pointInRect :: Point -> Rect -> Bool
rectMove :: Size -> Rect -> Rect
rectMoveTo :: Point -> Rect -> Rect
pointToRect :: Point -> Rect
centralPoint :: Rect -> Point
centralRect :: Rect -> Size -> Rect
rectStretchTo :: Size -> Rect -> Rect
disjointRects :: Rect -> Rect -> Bool
rectsDiff :: Rect -> Rect -> [Rect]
rectUnion :: Rect -> Rect -> Rect
rectSect :: Rect -> Rect -> Rect
Render
Colors
module Graphics.UI.Port.Colors
Bitmaps
data Bitmap
A bitmap. Resources for a bitmap are automatically de-allocated. Equality on bitmaps is only shallow equality: i.e. are the bitmap handles the same.
Instances
Eq Bitmap
data Codec
A Codec is an (image) format description.
Constructors
Codec
codecName :: !StringName of the codec.
codecDescr :: !StringDescription of the code.
codecMime :: !StringMIME string of the file format (i.e. "image/bmp")
codecExtensions :: ![String]File extensions used for this format
codecIsReadable :: !BoolCan decode files in this format
codecIsWritable :: !BoolCan encode bitmaps in the format
Instances
Eq Codec
Show Codec
Canvas
data DrawMode
The drawing mode.
Constructors
DrawCopyCopy directly to the canvas
DrawInvertInvert all colors
DrawXorxor the colors with the colors on the canvas. Doing this twice restores the original picture.
Instances
Eq DrawMode
Show DrawMode
data BufferMode
The drawing buffer.
Constructors
BufferedDraw via a buffer for smoother animations (double buffering)
UnBufferedDraw directly to the canvas
Instances
Eq BufferMode
Show BufferMode
data JoinStyle
The join style is applied to corners of figures (like rectangles).
Constructors
JoinBevelCut off corners diagonally.
JoinMiterLeave it as is.
JoinRoundRound off the corners.
Instances
Eq JoinStyle
Show JoinStyle
Read JoinStyle
data CapStyle
The cap style is applied to the end points of lines.
Constructors
CapRoundRound: put a disc at the logical end point.
CapSquareSquare: put a square at the logical end point.
CapFlatEnd flatly at the logical end point. (Doesn't stick out like square or round).
Instances
Eq CapStyle
Show CapStyle
Read CapStyle
data LineStyle
The line style is applied when drawing figures.
Constructors
LineSolidSolid line
LineDashDashed line
LineDotDotted line
LineDashDotDash - Dot pattern.
LineDashDotDotDash - Dot - Dot pattern.
LineCustomStyle [Word8]Custom pattern: each element specifies the pixel length of a dash.
Instances
Eq LineStyle
Show LineStyle
Read LineStyle
data HatchStyle
The HatchStyle is applied when filling an object.
Constructors
HatchSolidSolid pattern
HatchBDiagonalA 45-degree upward, left-to-right hatch
HatchFDiagonalA 45-degree downward, left-to-right hatch
HatchCrossHorizontal and vertical cross-hatch
HatchDiagCross45-degree crosshatch
HatchHorizontalHorizontal hatch
HatchVerticalVertical hatch
HatchPattern BitmapA bitmap pattern -- 8x8 pixel bitmaps are always supported.
Instances
Eq HatchStyle
Fonts
data Font
A font. Resources for a font are automatically de-allocated.
Instances
Eq Font
fontDef :: Font -> FontDef
data FontDef
A font definition.
Constructors
FontDef
fontName :: !FontNameThe name of font
fontSize :: !FontSizeThe size of font
fontWeight :: !FontWeightWeight between 100 and 900, 400 is normal.
fontStyle :: !FontStyleStyle
fontUnderline :: !BoolUnderlined
fontStrikeOut :: !BoolStriked out
Instances
Show FontDef
Eq FontDef
type FontName = String
Name of the font.
type FontSize = Int
Point size of a font.
type FontWeight = Int
Font weight between 100 and 900, 400 is normal.
data FontStyle
Font styles.
Constructors
Roman
Italic
Oblique
Instances
Show FontStyle
Eq FontStyle
Ord FontStyle
fontMinWeight :: Int
fontMaxWeight :: Int
fontNormalWeight :: Int
fontBoldWeight :: Int
data FontMetrics
The metrics of a font.
Constructors
FontMetrics
fontAscent :: !IntDistance between top and base line
fontDescent :: !IntDistance between bottom and base line
fontLeading :: !IntDistance between two text lines
fontMaxWidth :: !IntMax. character width including spacing
fontLineHeight :: FontMetrics -> Int
Standard line height of a font is the sum of its leading, ascent and descent.
Events
Modifiers
data Modifiers
The Modifiers indicate the meta keys that have been pressed (True) or not (False).
Constructors
Modifiers
shiftDown :: !Boolshift key down
controlDown :: !Boolcontrol key down
altDown :: !Boolalt key down
Instances
Eq Modifiers
Show Modifiers
noneDown :: Modifiers -> Bool
Test if no meta key was pressed.
justShift :: Modifiers
Construct a Modifiers structure with just Shift meta key pressed.
justAlt :: Modifiers
Construct a Modifiers structure with just Alt meta key pressed.
justControl :: Modifiers
Construct a Modifiers structure with just Ctrl meta key pressed.
noModifiers :: Modifiers
Construct a Modifiers structure with no meta keys pressed.
Mouse events
data MouseEvent
Mouse events
Constructors
MouseMove !Point !ModifiersMouse was moved over the client area of the window
MouseRightDown !Point !ModifiersMouse right button goes down
MouseRightUp !Point !ModifiersMouse right button goes up
MouseLeftDown !Point !ModifiersMouse left button goes down
MouseLeftUp !Point !ModifiersMouse left button goes up
MouseDoubleClick !Point !ModifiersMouse left button is double clicked
MouseDrag !Point !ModifiersMouse is moved over the client area of the window and its left button is down
Instances
Eq MouseEvent
Show MouseEvent
mousePos :: MouseEvent -> Point
Extract the position from a MouseEvent.
mouseModifiers :: MouseEvent -> Modifiers
Extract the modifiers from a MouseEvent.
Keyboard events
data KeyboardEvent
The KeyboardEvent type.
Constructors
KeyDown !Key !IsRepeatKeyKey is down
KeyUp !KeyKey goes up
KeyLost !KeyThe key was down when the widget lost focus
Instances
Eq KeyboardEvent
Show KeyboardEvent
data Key
Keyboard keys. A Shift-character combinations gets translated into an upper-case character and a Ctrl-character in a control character. Alt-character combinations are normally processed by the system to handle menu's etc.
Constructors
KeyBegin Modifiers
KeyClear Modifiers
KeyDelete Modifiers
KeyEnd Modifiers
KeyArrowDown Modifiers
KeyArrowLeft Modifiers
KeyArrowRight Modifiers
KeyArrowUp Modifiers
KeyPageDown Modifiers
KeyPageUp Modifiers
KeyEscape Modifiers
KeyEnter Modifiers
KeyTab Modifiers
KeyBackSpace Modifiers
KeyF1 Modifiers
KeyF2 Modifiers
KeyF3 Modifiers
KeyF4 Modifiers
KeyF5 Modifiers
KeyF6 Modifiers
KeyF7 Modifiers
KeyF8 Modifiers
KeyF9 Modifiers
KeyF10 Modifiers
KeyF11 Modifiers
KeyF12 Modifiers
KeyF13 Modifiers
KeyF14 Modifiers
KeyF15 Modifiers
KeyHelp Modifiers
KeyChar !Char
KeyAltChar !Char
KeyNull
Instances
Eq Key
Show Key
keyModifiers :: Key -> Modifiers
Extract the modifiers from a key
keyboardKey :: KeyboardEvent -> Key
Extract the key from a KeyboardEvent
keyboardRepeat :: KeyboardEvent -> Bool
Is this a key that is held down.
Document interface
data DocumentInterface
The document interface type of interactive processes.
Constructors
NDINo document interface
SDISingle document interface
MDIMultiple document interface
Instances
Eq DocumentInterface
Show DocumentInterface
PositionType
data PositionType
Constructors
PosLeft
PosTop
PosRight
PosBottom
Instances
Eq PositionType
Show PositionType
Primitive Handles
type WindowHandle = Ptr WH
Abstract handle to a window
type CanvasHandle = Ptr CH
Abstract handle to a drawing context
type MenuHandle = Ptr MH
Abstract handle to a menu
type FontHandle = Ptr FH
Abstract handle to a font
type BitmapHandle = Ptr BH
Abstract handle to a bitmap
type TimerHandle = Ptr TH
Abstract handle to a timer
type ToolHandle = Ptr TLH
Abstract handle to a tool
nullHandle :: Ptr a
A null handle. Use with care.
Marshalling to C
toCDrawMode :: DrawMode -> CInt
toCBufferMode :: BufferMode -> CBool
toCJoinStyle :: JoinStyle -> CInt
toCCapStyle :: CapStyle -> CInt
withCLineStyle :: LineStyle -> (CInt -> CInt -> Ptr CUChar -> IO a) -> IO a
withCHatchStyle :: HatchStyle -> (CInt -> BitmapHandle -> IO a) -> IO a
withCBitmap :: Bitmap -> (BitmapHandle -> IO a) -> IO a
fromCBitmap :: BitmapHandle -> IO Bitmap
withCFont :: Font -> (FontHandle -> IO a) -> IO a
fromCFont :: FontDef -> FontHandle -> IO Font
withCFontDef :: FontDef -> (CString -> CInt -> CInt -> CInt -> IO a) -> IO a
withCFontDefResult :: (Ptr CString -> Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CBool -> Ptr CBool -> IO ()) -> IO FontDef
fromCFontDef :: CString -> CInt -> CInt -> CInt -> CBool -> CBool -> IO FontDef
fromCStyle :: CInt -> (FontStyle, Bool, Bool)
fromCWeight :: CInt -> Int
withCFontMetricsResult :: (Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()) -> IO FontMetrics
fromCFontMetrics :: CInt -> CInt -> CInt -> CInt -> FontMetrics
withCPoint :: Point -> (CInt -> CInt -> IO a) -> IO a
withCPointResult :: (Ptr CInt -> IO ()) -> IO Point
fromCPoint :: CInt -> CInt -> Point
withCSize :: Size -> (CInt -> CInt -> IO a) -> IO a
withCSizeResult :: (Ptr CInt -> IO ()) -> IO Size
fromCSize :: CInt -> CInt -> Size
withCRect :: Rect -> (CInt -> CInt -> CInt -> CInt -> IO a) -> IO a
withCRectResult :: (Ptr CInt -> IO ()) -> IO Rect
fromCRect :: CInt -> CInt -> CInt -> CInt -> Rect
fromCModifiers :: CWord -> Modifiers
toCModifiers :: Modifiers -> CWord
fromCKey :: CInt -> CWord -> Key
toCKey :: Key -> (CInt, CWord)
fromCMouseEvent :: CInt -> CInt -> CInt -> CWord -> MouseEvent
fromCKeyboardEvent :: CInt -> CInt -> CWord -> KeyboardEvent
toCDocumentInterface :: DocumentInterface -> CInt
toCPositionType :: PositionType -> CInt
fromCPositionType :: CInt -> PositionType
fromCInt :: CInt -> Int
toCInt :: Int -> CInt
type CWord = CUInt
fromCWord :: CWord -> Int
toCWord :: Int -> CWord
type CBool = CInt
fromCBool :: CBool -> Bool
toCBool :: Bool -> CBool
fromCChar :: CChar -> Char
toCChar :: Char -> CChar
withCStrings :: [String] -> (Ptr CChar -> IO a) -> IO a
peekCStrings :: Ptr CChar -> IO [String]
resultCString :: IO CString -> IO String
Convert and free a c-string.
resultCStrings :: IO (Ptr CChar) -> IO [String]
Convert and free a c-string of c-strings.
Configuration
module Graphics.UI.Port.ConfigKey
Produced by Haddock version 0.6