ContentsIndex
Graphics.UI.WX.Types
Contents
Basic Types
Objects
Identifiers
Mutable variables
Bits
Booleans
Misc.
Graphical types
Colors
System colors
Font
Brush
Pen
Geometrical types
Points
Sizes
Vectors
Rectangles
IO Control
Description
Synopsis
data Orientation
= Horizontal
| Vertical
(#) :: obj -> (obj -> a) -> a
feed :: a -> (a -> b) -> b
feed2 :: a -> b -> (a -> b -> c) -> c
data Object a
objectNull :: Object a
objectIsNull :: Object a -> Bool
objectCast :: Object a -> Object b
objectIsManaged :: Object a -> Bool
objectDelete :: WxObject a -> IO ()
type Id = Int
idAny :: Id
idCreate :: IO Id
type Var a = IORef a
varCreate :: a -> IO (Var a)
varGet :: Var a -> IO a
varSet :: Var a -> a -> IO ()
varUpdate :: Var a -> (a -> a) -> IO a
varSwap :: Var a -> a -> IO a
class Eq b => BitMask b where
assocBitMask :: [(b, Int)]
toBitMask :: b -> Int
fromBitMask :: Int -> b
setBitMask :: b -> Int -> Int
mask :: BitMask b => [b] -> Int
(.+.) :: Int -> Int -> Int
(.-.) :: Int -> BitFlag -> Int
bits :: [Int] -> Int
bitsSet :: Int -> Int -> Bool
boolFromInt :: Int -> Bool
intFromBool :: Bool -> Int
type Style = Int
type EventId = Int
data TreeItem
data Color
rgb :: Int -> Int -> Int -> Color
colorRGB :: Int -> Int -> Int -> Color
colorRed :: Color -> Int
colorGreen :: Color -> Int
colorBlue :: Color -> Int
black :: Color
darkgrey :: Color
dimgrey :: Color
mediumgrey :: Color
grey :: Color
lightgrey :: Color
white :: Color
red :: Color
green :: Color
blue :: Color
cyan :: Color
magenta :: Color
yellow :: Color
data SystemColor
= ColorScrollBar
| ColorBackground
| ColorActiveCaption
| ColorInactiveCaption
| ColorMenu
| ColorWindow
| ColorWindowFrame
| ColorMenuText
| ColorWindowText
| ColorCaptionText
| ColorActiveBorder
| ColorInactiveBorder
| ColorAppWorkspace
| ColorHighlight
| ColorHighlightText
| ColorBtnFace
| ColorBtnShadow
| ColorGrayText
| ColorBtnText
| ColorInactiveCaptionText
| ColorBtnHighlight
| Color3DDkShadow
| Color3DLight
| ColorInfoText
| ColorInfoBk
| ColorDesktop
| Color3DFace
| Color3DShadow
| Color3DHighlight
| Color3DHilight
| ColorBtnHilight
colorSystem :: SystemColor -> Color
data FontStyle = FontStyle {
_fontSize :: !Int
_fontFamily :: !FontFamily
_fontShape :: !FontShape
_fontWeight :: !FontWeight
_fontUnderline :: !Bool
_fontFace :: !String
_fontEncoding :: !Int
}
data FontFamily
= FontDefault
| FontDecorative
| FontRoman
| FontScript
| FontSwiss
| FontModern
data FontShape
= ShapeNormal
| ShapeItalic
| ShapeSlant
data FontWeight
= WeightNormal
| WeightBold
| WeightLight
fontDefault :: FontStyle
fontSwiss :: FontStyle
fontSmall :: FontStyle
fontItalic :: FontStyle
fontFixed :: FontStyle
data BrushStyle = BrushStyle {
_brushKind :: !BrushKind
_brushColor :: !Color
}
data BrushKind
= BrushTransparent
| BrushSolid
| BrushHatch {
_brushHatch :: !HatchStyle
}
| BrushStipple {
_brushBitmap :: !(Bitmap ())
}
data HatchStyle
= HatchBDiagonal
| HatchCrossDiag
| HatchFDiagonal
| HatchCross
| HatchHorizontal
| HatchVertical
brushDefault :: BrushStyle
brushTransparent :: BrushStyle
data PenStyle = PenStyle {
_penKind :: !PenKind
_penColor :: !Color
_penWidth :: !Int
_penCap :: !CapStyle
_penJoin :: !JoinStyle
}
data PenKind
= PenTransparent
| PenSolid
| PenDash {
_penDash :: !DashStyle
}
| PenHatch {
_penHatch :: !HatchStyle
}
| PenStipple {
_penBitmap :: !(Bitmap ())
}
data CapStyle
= CapRound
| CapProjecting
| CapButt
data JoinStyle
= JoinRound
| JoinBevel
| JoinMiter
data DashStyle
= DashDot
| DashLong
| DashShort
| DashDotShort
penDefault :: PenStyle
penColored :: Color -> Int -> PenStyle
penTransparent :: PenStyle
data Point = Point {
pointX :: !Int
pointY :: !Int
}
point :: Int -> Int -> Point
pt :: Int -> Int -> Point
pointFromVec :: Vector -> Point
pointFromSize :: Size -> Point
pointZero :: Point
pointNull :: Point
pointMove :: Vector -> Point -> Point
pointMoveBySize :: Point -> Size -> Point
pointAdd :: Point -> Point -> Point
pointSub :: Point -> Point -> Point
pointScale :: Point -> Int -> Point
data Size = Size {
sizeW :: !Int
sizeH :: !Int
}
sz :: Int -> Int -> Size
sizeFromPoint :: Point -> Size
sizeFromVec :: Vector -> Size
sizeZero :: Size
sizeNull :: Size
sizeEncloses :: Size -> Size -> Bool
sizeMin :: Size -> Size -> Size
sizeMax :: Size -> Size -> Size
data Vector = Vector {
vecX :: !Int
vecY :: !Int
}
vector :: Int -> Int -> Vector
vec :: Int -> Int -> Vector
vecFromPoint :: Point -> Vector
vecFromSize :: Size -> Vector
vecZero :: Vector
vecNull :: Vector
vecNegate :: Vector -> Vector
vecOrtogonal :: Vector -> Vector
vecAdd :: Vector -> Vector -> Vector
vecSub :: Vector -> Vector -> Vector
vecScale :: Vector -> Int -> Vector
vecBetween :: Point -> Point -> Vector
vecLength :: Vector -> Double
data Rect = Rect {
rectLeft :: !Int
rectTop :: !Int
rectWidth :: !Int
rectHeight :: !Int
}
rectTopLeft :: Rect -> Point
rectTopRight :: Rect -> Point
rectBottomLeft :: Rect -> Point
rectBottomRight :: Rect -> Point
rectBottom :: Rect -> Int
rectRight :: Rect -> Int
rect :: Point -> Size -> Rect
rectBetween :: Point -> Point -> Rect
rectFromSize :: Size -> Rect
rectZero :: Rect
rectNull :: Rect
rectSize :: Rect -> Size
rectIsEmpty :: Rect -> Bool
rectContains :: Rect -> Point -> Bool
rectMoveTo :: Rect -> Point -> Rect
rectFromPoint :: Point -> Rect
rectCentralPoint :: Rect -> Point
rectCentralRect :: Rect -> Size -> Rect
rectStretchTo :: Rect -> Size -> Rect
rectMove :: Rect -> Vector -> Rect
rectOverlaps :: Rect -> Rect -> Bool
rectsDiff :: Rect -> Rect -> [Rect]
rectUnion :: Rect -> Rect -> Rect
rectOverlap :: Rect -> Rect -> Rect
rectUnions :: [Rect] -> Rect
unitIO :: IO a -> IO ()
bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket_ :: IO a -> IO b -> IO c -> IO c
finally :: IO a -> IO b -> IO a
finalize :: IO b -> IO a -> IO a
when :: Bool -> IO () -> IO ()
Basic Types
data Orientation
The orientation of a widget.
Constructors
Horizontal
Vertical
show/hide Instances
Objects
(#) :: obj -> (obj -> a) -> a

Reverse application, i.e. x # f = f x. Useful for an object oriented style of programming.

 (frame # frameSetTitle) "hi"
feed :: a -> (a -> b) -> b
Inverse application, i.e. feed x f = f x.
feed2 :: a -> b -> (a -> b -> c) -> c
Composed Inverse application, i.e. feed2 x y f = f x y.
data Object a

An Object a is a pointer to an object of type a. The a parameter is used to encode the inheritance relation. When the type parameter is unit (), it denotes an object of exactly that class, when the parameter is a type variable a, it specifies an object that is at least an instance of that class. For example in wxWindows, we have the following class hierarchy:

 EvtHandler
   |- Window
        |- Frame
        |- Control
            |- Button
            |- Radiobox

In wxHaskell, all the creation functions will return objects of exactly that class and use the () type:

 frameCreate :: Window a -> ... -> IO (Frame ())
 buttonCreate :: Window a -> ... -> IO (Button ())
 ...

In contrast, all the this (or self) pointers of methods can take objects of any instance of that class and have a type variable, for example:

 windowSetClientSize :: Window a -> Size -> IO ()
 controlSetLabel     :: Control a -> String -> IO ()
 buttonSetDefault    :: Button a -> IO ()

This means that we can use windowSetClientSize on any window, including buttons and frames, but we can only use controlSetLabel on controls, not includeing frames.

In wxHaskell, this works since a Frame () is actually a type synonym for Window (CFrame ()) (where CFrame is an abstract data type). We can thus pass a value of type Frame () to anything that expects some Window a. For a button this works too, as it is a synonym for Control (CButton ()) which is in turn a synonym for Window (CControl (CButton ())). Note that we can't pass a frame to something that expects a value of type Control a. Of course, a Window a is actually a type synonym for EvtHandler (CWindow a). If you study the documentation in Graphics.UI.WXH.WxcClasses closely, you can discover where this chain ends :-).

Objects are not automatically deleted. Normally you can use a delete function like windowDelete to delete an object. However, almost all objects in the wxWindows library are automatically deleted by the library. The only objects that should be used with care are resources as bitmaps, fonts and brushes.

show/hide Instances
objectNull :: Object a
A null object. Use with care.
objectIsNull :: Object a -> Bool
Test for null object.
objectCast :: Object a -> Object b
Cast an object to another type. Use with care.
objectIsManaged :: Object a -> Bool
Is this a managed object.
objectDelete :: WxObject a -> IO ()
Delete a wxObject, works for managed and unmanaged objects.
Identifiers
type Id = Int
An Id is used to identify objects during event handling.
idAny :: Id
When creating a new window you may specify idAny to let wxWindows assign an unused identifier to it automatically. Furthermore, it can be used in an event connection to handle events for any identifier.
idCreate :: IO Id
Create a new unique identifier.
Mutable variables
type Var a = IORef a
A mutable variable. Use this instead of MVars or IORefs to accomodate for future expansions with possible concurrency.
varCreate :: a -> IO (Var a)
Create a fresh mutable variable.
varGet :: Var a -> IO a
Get the value of a mutable variable.
varSet :: Var a -> a -> IO ()
Set the value of a mutable variable.
varUpdate :: Var a -> (a -> a) -> IO a
Update the value of a mutable variable and return the old value.
varSwap :: Var a -> a -> IO a
Swap the value of a mutable variable.
Bits
class Eq b => BitMask b where
Data types that can be represented through a bit mask. Only the assocBitMask method is required for a new instance.
Methods
assocBitMask :: [(b, Int)]
Give the association between the constructors and the bits. If a constructor corresponds to no bits set, it should come as the last element.
toBitMask :: b -> Int
Convert to a bitmask
fromBitMask :: Int -> b
Convert from a bitmask
setBitMask :: b -> Int -> Int
Set the correct bits corresponding to a constructor in a mask.
show/hide Instances
mask :: BitMask b => [b] -> Int
Create a bitmask from a list of types.
(.+.) :: Int -> Int -> Int
Bitwise or of two bit masks.
(.-.) :: Int -> BitFlag -> Int
Unset certain bits in a bitmask.
bits :: [Int] -> Int
Bitwise or of a list of bit masks.
bitsSet :: Int -> Int -> Bool
(bitsSet mask i) tests if all bits in mask are also set in i.
Booleans
boolFromInt :: Int -> Bool
intFromBool :: Bool -> Int
Misc.
type Style = Int
A Style is normally used as a flag mask to specify some window style
type EventId = Int
An EventId is identifies specific events.
data TreeItem
Identifies tree items. Note: Replaces the TreeItemId object and takes automatically care of allocation issues.
show/hide Instances
Graphical types
Colors
data Color
An abstract data type to define colors.
show/hide Instances
rgb :: Int -> Int -> Int -> Color
Create a color from a red/green/blue triple.
colorRGB :: Int -> Int -> Int -> Color
Create a color from a red/green/blue triple.
colorRed :: Color -> Int
Returns a red color component
colorGreen :: Color -> Int
Returns a green color component
colorBlue :: Color -> Int
Returns a blue color component
black :: Color
darkgrey :: Color
dimgrey :: Color
mediumgrey :: Color
grey :: Color
lightgrey :: Color
white :: Color
red :: Color
green :: Color
blue :: Color
cyan :: Color
magenta :: Color
yellow :: Color
System colors
data SystemColor
System Colors.
Constructors
ColorScrollBarThe scrollbar grey area.
ColorBackgroundThe desktop colour.
ColorActiveCaptionActive window caption.
ColorInactiveCaptionInactive window caption.
ColorMenuMenu background.
ColorWindowWindow background.
ColorWindowFrameWindow frame.
ColorMenuTextMenu text.
ColorWindowTextText in windows.
ColorCaptionTextText in caption, size box and scrollbar arrow box.
ColorActiveBorderActive window border.
ColorInactiveBorderInactive window border.
ColorAppWorkspaceBackground colour MDI -- ^applications.
ColorHighlightItem(s) selected in a control.
ColorHighlightTextText of item(s) selected in a control.
ColorBtnFaceFace shading on push buttons.
ColorBtnShadowEdge shading on push buttons.
ColorGrayTextGreyed (disabled) text.
ColorBtnTextText on push buttons.
ColorInactiveCaptionTextColour of text in active captions.
ColorBtnHighlightHighlight colour for buttons (same as 3DHILIGHT).
Color3DDkShadowDark shadow for three-dimensional display elements.
Color3DLightLight colour for three-dimensional display elements.
ColorInfoTextText colour for tooltip controls.
ColorInfoBkBackground colour for tooltip controls.
ColorDesktopSame as BACKGROUND.
Color3DFaceSame as BTNFACE.
Color3DShadowSame as BTNSHADOW.
Color3DHighlightSame as BTNHIGHLIGHT.
Color3DHilightSame as BTNHIGHLIGHT.
ColorBtnHilightSame as BTNHIGHLIGHT.
show/hide Instances
colorSystem :: SystemColor -> Color
Convert a system color to a color.
Font
data FontStyle

Font descriptor. The font is normally specified thru the FontFamily, giving some degree of portability. The _fontFace can be used to specify the exact (platform dependent) font.

Note that the original wxWindows FontStyle is renamed to FontShape.

Constructors
FontStyle
_fontSize :: !Int
_fontFamily :: !FontFamily
_fontShape :: !FontShape
_fontWeight :: !FontWeight
_fontUnderline :: !Bool
_fontFace :: !Stringnormally ""
_fontEncoding :: !Intnormally wxFONTENCODING_DEFAULT
show/hide Instances
data FontFamily
Standard font families.
Constructors
FontDefaultA system default font.
FontDecorativeDecorative font.
FontRomanFormal serif font.
FontScriptHand writing font.
FontSwissSans-serif font.
FontModernFixed pitch font.
show/hide Instances
data FontShape
The font style.
Constructors
ShapeNormal
ShapeItalic
ShapeSlant
show/hide Instances
data FontWeight
The font weight.
Constructors
WeightNormal
WeightBold
WeightLight
show/hide Instances
fontDefault :: FontStyle
Default 10pt font.
fontSwiss :: FontStyle
Default 10pt sans-serif font.
fontSmall :: FontStyle
Default 8pt font.
fontItalic :: FontStyle
Default 10pt italic.
fontFixed :: FontStyle
Monospaced font, 10pt.
Brush
data BrushStyle
Brush style.
Constructors
BrushStyle
_brushKind :: !BrushKind
_brushColor :: !Color
show/hide Instances
data BrushKind
Brush kind.
Constructors
BrushTransparentNo filling
BrushSolidSolid color
BrushHatchHatch pattern
_brushHatch :: !HatchStyle
BrushStippleBitmap pattern (on win95 only 8x8 bitmaps are supported)
_brushBitmap :: !(Bitmap ())
show/hide Instances
data HatchStyle
Hatch style.
Constructors
HatchBDiagonalBackward diagonal
HatchCrossDiagCrossed diagonal
HatchFDiagonalForward diagonal
HatchCrossCrossed orthogonal
HatchHorizontalHorizontal
HatchVerticalVertical
show/hide Instances
brushDefault :: BrushStyle
Default brush (transparent, black).
brushTransparent :: BrushStyle
A transparent brush.
Pen
data PenStyle
Pen style.
Constructors
PenStyle
_penKind :: !PenKind
_penColor :: !Color
_penWidth :: !Int
_penCap :: !CapStyle
_penJoin :: !JoinStyle
show/hide Instances
data PenKind
Pen kinds.
Constructors
PenTransparentNo edge.
PenSolid
PenDash
_penDash :: !DashStyle
PenHatch
_penHatch :: !HatchStyle
PenStipple_penColor is ignored
_penBitmap :: !(Bitmap ())
show/hide Instances
data CapStyle
Cap style
Constructors
CapRoundEnd points are rounded
CapProjecting
CapButt
show/hide Instances
data JoinStyle
Join style.
Constructors
JoinRoundCorners are rounded
JoinBevelCorners are bevelled
JoinMiterCorners are blocked
show/hide Instances
data DashStyle
Dash style
Constructors
DashDot
DashLong
DashShort
DashDotShort
show/hide Instances
penDefault :: PenStyle
Default pen (PenStyle PenSolid black 1 CapRound JoinRound)
penColored :: Color -> Int -> PenStyle
A solid pen with a certain color and width.
penTransparent :: PenStyle
A transparent pen.
Geometrical types
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
pointX :: !Intx component of a point.
pointY :: !Inty component of a point.
show/hide Instances
point :: Int -> Int -> Point
Construct a point.
pt :: Int -> Int -> Point
Shorter function to construct a point.
pointFromVec :: Vector -> Point
pointFromSize :: Size -> Point
pointZero :: Point
Point at the origin.
pointNull :: Point
A null point is not a legal point (x and y are -1) and can be used for some wxWindows functions to select a default point.
pointMove :: Vector -> Point -> Point
pointMoveBySize :: Point -> Size -> Point
pointAdd :: Point -> Point -> Point
pointSub :: Point -> Point -> Point
pointScale :: Point -> Int -> Point
Sizes
data Size
A Size has a width and height.
Constructors
Size
sizeW :: !Intthe width of a size
sizeH :: !Intthe height of a size
show/hide Instances
sz :: Int -> Int -> Size
Short function to construct a size
sizeFromPoint :: Point -> Size
sizeFromVec :: Vector -> Size
sizeZero :: Size
sizeNull :: Size
A null size is not a legal size (width and height are -1) and can be used for some wxWindows functions to select a default size.
sizeEncloses :: Size -> Size -> Bool
Returns True if the first size totally encloses the second argument.
sizeMin :: Size -> Size -> Size
The minimum of two sizes.
sizeMax :: Size -> Size -> Size
The maximum of two sizes.
Vectors
data Vector
A vector with an x and y delta.
Constructors
Vector
vecX :: !Intdelta-x component of a vector
vecY :: !Intdelta-y component of a vector
show/hide Instances
vector :: Int -> Int -> Vector
Construct a vector.
vec :: Int -> Int -> Vector
Short function to construct a vector.
vecFromPoint :: Point -> Vector
vecFromSize :: Size -> Vector
vecZero :: Vector
A zero vector
vecNull :: Vector
A null vector has a delta x and y of -1 and can be used for some wxWindows functions to select a default vector.
vecNegate :: Vector -> Vector
vecOrtogonal :: Vector -> Vector
vecAdd :: Vector -> Vector -> Vector
vecSub :: Vector -> Vector -> Vector
vecScale :: Vector -> Int -> Vector
vecBetween :: Point -> Point -> Vector
vecLength :: Vector -> Double
Rectangles
data Rect
A rectangle is defined by the left x coordinate, the top y coordinate, the width and the height.
Constructors
Rect
rectLeft :: !Int
rectTop :: !Int
rectWidth :: !Int
rectHeight :: !Int
show/hide Instances
rectTopLeft :: Rect -> Point
rectTopRight :: Rect -> Point
rectBottomLeft :: Rect -> Point
rectBottomRight :: Rect -> Point
rectBottom :: Rect -> Int
rectRight :: Rect -> Int
rect :: Point -> Size -> Rect
Create a rectangle at a certain (upper-left) point with a certain size.
rectBetween :: Point -> Point -> Rect
Construct a (positive) rectangle between two (arbitrary) points.
rectFromSize :: Size -> Rect
Create a rectangle of a certain size with the upper-left corner at (pt 0 0).
rectZero :: Rect
An empty rectangle at (0,0).
rectNull :: Rect
An null rectangle is not a valid rectangle (Rect -1 -1 -1 -1) but can used for some wxWindows functions to select a default rectangle. (i.e. frameCreate).
rectSize :: Rect -> Size
Get the size of a rectangle.
rectIsEmpty :: Rect -> Bool
rectContains :: Rect -> Point -> Bool
rectMoveTo :: Rect -> Point -> Rect
rectFromPoint :: Point -> Rect
rectCentralPoint :: Rect -> Point
rectCentralRect :: Rect -> Size -> Rect
rectStretchTo :: Rect -> Size -> Rect
rectMove :: Rect -> Vector -> Rect
rectOverlaps :: Rect -> Rect -> Bool
rectsDiff :: Rect -> Rect -> [Rect]
A list with rectangles that constitute the difference between two rectangles.
rectUnion :: Rect -> Rect -> Rect
rectOverlap :: Rect -> Rect -> Rect
The intersection between two rectangles.
rectUnions :: [Rect] -> Rect
IO Control
unitIO :: IO a -> IO ()
Ignore the result of an IO action.
bracket
:: IO acomputation to run first (acquire resource)
-> (a -> IO b)computation to run last (release resource)
-> (a -> IO c)computation to run in-between (use resource)
-> IO c
Properly release resources, even in the event of an exception.
bracket_
:: IO acomputation to run first (acquire resource)
-> IO bcomputation to run last (release resource)
-> IO ccomputation to run in-between (use resource)
-> IO c
Specialized variant of bracket where the return value is not required.
finally
:: IO acomputation to run first
-> IO bcomputation to run last (release resource)
-> IO a
Run some computation afterwards, even if an exception occurs.
finalize
:: IO bcomputation to run last (release resource)
-> IO acomputation to run first
-> IO a
Run some computation afterwards, even if an exception occurs. Equals finally but with the arguments swapped.
when :: Bool -> IO () -> IO ()
Perform an action when a test succeeds.
Produced by Haddock version 0.8