Skip to content

Instantly share code, notes, and snippets.

@xenophobia
Created April 12, 2012 14:16
Show Gist options
  • Save xenophobia/2367624 to your computer and use it in GitHub Desktop.
Save xenophobia/2367624 to your computer and use it in GitHub Desktop.
drawString :: DrawingArea -> DrawWindow -> RGB -> Coordinate -> String -> IO ()
drawString drawArea drawWin (r, g, b) (x, y) str = do
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
-----------------------------------------------------------------------------------
-- タイムラインのフィールドにデータを描画
drawTimelineData :: GUI -> [Tweet] -> IO ()
drawTimelineData gui tweets = do
let home = homeTimeline gui
field = timelineField home
tlText = foldl (\s -> \t -> s ++ (show t) ++ "\n") "" tweets
-- 描画イベントを発生させる
drawWin <- widgetGetDrawWindow field
onExpose field (const $ GUI.drawString field drawWin (0, 0, 0) (0, 0) tlText >> return True)
drawWindowClearAreaExpose drawWin 0 0 300 1000
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment