Skip to content

Instantly share code, notes, and snippets.

@xenophobia
Created April 12, 2012 14:07
Show Gist options
  • Save xenophobia/2367557 to your computer and use it in GitHub Desktop.
Save xenophobia/2367557 to your computer and use it in GitHub Desktop.
drawString :: DrawingArea -> RGB -> Coordinate -> String -> IO ()
drawString drawArea (r, g, b) (x, y) str = do
drawWin <- widgetGetDrawWindow drawArea
let gcVal = newGCValues {foreground = Color r g b}
gc <- gcNewWithValues drawWin gcVal
layout <- widgetCreateLayout drawArea str
layoutSetText layout str
layoutSetWrap layout WrapWholeWords
layoutSetWidth layout . Just $ 300
lineCount <- layoutGetLineCount layout
widgetSetSizeRequest drawArea 300 1000
drawLayout drawWin gc 0 0 layout
drawWindowClearAreaExpose drawWin 0 0 300 1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment