我想在背景上绘制(比如矩形等),然后让它在上面渲染组件。这些组件将在我绘制的之上。有没有办法做到这一点?
这是这个概念的一个例子。这仅显示矩形。所以......只需要一些方法来告诉它也去渲染组件。
{-# LANGUAGE PackageImports #-}
import Graphics.UI.Gtk
import Graphics.UI.Gtk.Gdk.EventM
import Graphics.UI.Gtk.Gdk.GC
import "mtl" Control.Monad.Trans(liftIO)
main = do
initGUI
window <- windowNew
window `onDestroy` mainQuit
windowSetDefaultSize window 800 600
windowSetPosition window WinPosCenter
table <- tableNew 3 3 False
button <- buttonNewWithLabel "Test Button"
tableAttachDefaults table button 1 2 1 2
containerAdd window table
table `on` exposeEvent $ update
widgetShowAll table
widgetShowAll window
mainGUI
update = do
win <- eventWindow
liftIO $ do
gc <- gcNew win
drawRectangle win gc False 10 10 90 90
return True