Copyright | (c) Daniel Winograd-Cort 2015 |
---|---|
License | see the LICENSE file in the distribution |
Maintainer | dwc@cs.yale.edu |
Stability | experimental |
Safe Haskell | None |
Language | Haskell98 |
- newtype UIText = UIText {
- unwrapUIT :: [(Maybe RGB, BitmapFont, String)]
- class UITexty a where
- uitextToString :: UIText -> String
- splitUIText :: Int -> UIText -> (UIText, UIText)
- takeUIText :: Int -> UIText -> UIText
- dropUIText :: Int -> UIText -> UIText
- uitextLen :: UIText -> Int
- pureUIText :: String -> UIText
- appendUIText :: (UITexty s1, UITexty s2) => s1 -> s2 -> UIText
- coloredUIText :: UITexty s => Color -> s -> UIText
- rgbUIText :: UITexty s => Maybe RGB -> s -> UIText
- fontUIText :: UITexty s => BitmapFont -> s -> UIText
- textWidth :: UITexty s => s -> Int
- textWithinPixels :: UITexty s => Int -> s -> (UIText, UIText)
- textHeight :: UITexty s => s -> Int
- data WrapSetting
- prepText :: UITexty s => WrapSetting -> Double -> Rect -> s -> ([Point], [UIText])
- textWidth' :: BitmapFont -> String -> Int
- textWithinPixels' :: BitmapFont -> Int -> String -> (String, String)
- textHeight' :: BitmapFont -> String -> Int
- uitextLines :: UIText -> [UIText]
- uitextWords :: UIText -> [UIText]
- data BitmapFont :: *
Documentation
Text in UISF can be rendered in multiple fonts and colors, so we need a more powerful data type to encode it. The UIText data type does this.
To retain easy compatibility with Strings (or other text representations), we also provide the UITexty class, which is how all widgets that accept UIText should do so.
uitextToString :: UIText -> String Source
Removes all font and color formatting from a UIText, returning its underlying String representation.
takeUIText :: Int -> UIText -> UIText Source
Take a certain number of characters off of a UIText
dropUIText :: Int -> UIText -> UIText Source
Drop a certain number of characters from a UIText
pureUIText :: String -> UIText Source
Lifts a String to a UIText (with default color and font).
appendUIText :: (UITexty s1, UITexty s2) => s1 -> s2 -> UIText Source
Appends two UITexty objects together.
coloredUIText :: UITexty s => Color -> s -> UIText Source
Colors a UITexty object.
rgbUIText :: UITexty s => Maybe RGB -> s -> UIText Source
Colors a UITexty object with an exact RGB value.
fontUIText :: UITexty s => BitmapFont -> s -> UIText Source
Converts the UITexty object to the given font.
textWidth :: UITexty s => s -> Int Source
Returns the width of the String in pixels as it will be rendered
textWithinPixels :: UITexty s => Int -> s -> (UIText, UIText) Source
Given a String and a number of pixels, returns the leading substring that fits within the horizontal number of pixels along with the remaining text of the String.
textHeight :: UITexty s => s -> Int Source
Returns the height of the String in pixels as it will be rendered
data WrapSetting Source
The Wrap Setting is used to determine how to split up a long piece of text.
:: UITexty s | |
=> WrapSetting | Whether we prefer newer or older text |
-> Double | Line spacing |
-> Rect | Bounding Box |
-> s | The text to print (which is allowed to have new lines) |
-> ([Point], [UIText]) |
Turn the given String into a list of Strings. If the wrap setting is NoWrap, then this is basically just the lines function. If it is CharWrap or WordWrap, then no string in the list will be wider than the width of the bounding box. The returned list of points indicate each Point where a line should be drawn. Note that this list may not be the same length as the list of strings.
Typically, this will be used in conjunction with zip and textLines to produce text graphics.
textWidth' :: BitmapFont -> String -> Int Source
Returns the text width of a String rendered in the given bitmap font.
textWithinPixels' :: BitmapFont -> Int -> String -> (String, String) Source
Splits a String based on what can fit within the given number of pixels (the fst of the result) and what's left over (the snd).
textHeight' :: BitmapFont -> String -> Int Source
Returns the text height of a String rendered in the given bitmap font.
uitextLines :: UIText -> [UIText] Source
The common String lines
function applicable to UIText.
uitextWords :: UIText -> [UIText] Source
The common String words
function applicable to UIText.
data BitmapFont :: *
The bitmap fonts available in GLUT. The exact bitmap to be used is defined by the standard X glyph bitmaps for the X font with the given name.
Fixed8By13 | A fixed width font with every character fitting in an 8
by 13 pixel rectangle.
( |
Fixed9By15 | A fixed width font with every character fitting in an 9
by 15 pixel rectangle.
( |
TimesRoman10 | A 10-point proportional spaced Times Roman font.
( |
TimesRoman24 | A 24-point proportional spaced Times Roman font.
( |
Helvetica10 | A 10-point proportional spaced Helvetica font.
( |
Helvetica12 | A 12-point proportional spaced Helvetica font.
( |
Helvetica18 | A 18-point proportional spaced Helvetica font.
( |