cl-gtk2を使ってウィンドウに絵を書いてみます。
;;(asdf:load-system :cl-gtk2-glib)
;;(asdf:load-system :cl-gtk2-gdk)
;;(asdf:load-system :cl-gtk2-cairo)
(defun run-test-1 ()
(let ((out *standard-output*))
(gtk:within-main-loop
(let ((window (make-instance 'gtk:gtk-window
:type :toplevel
:window-position :center
:title "run-test-1"
:default-width 300
:default-height 100))
(area (make-instance 'gtk:drawing-area
:default-width 100 :default-height 100))
(button (make-instance 'gtk:button :label "はろー, World"))
(v-box (make-instance 'gtk:v-box)))
(gobject:g-signal-connect button "clicked"
(lambda (b)
(format out "Hello,World Clicked: ~A~%" b)
(multiple-value-bind (width height)
(gdk:drawable-get-size (gtk:widget-window area))
(cl-gtk2-cairo:with-gdk-context
(ctx (gtk:widget-window area))
(cairo:with-context (ctx)
(cairo:set-source-rgb (random 1.0)
(random 1.0)
(random 1.0))
(cairo:move-to (random width) (random height))
(cairo:line-to (random width) (random height))
(cairo:stroke)
nil)))))
(gtk:container-add window v-box)
(gtk:box-pack-start v-box button :expand nil)
(gtk:box-pack-start v-box area)
(gtk:widget-show window :all t)))))
画面上部のボタンを押すと、ウィンドウに線を描きます。
ウィジェットを並べるにはv-boxやh-boxその他が使えるようです。
0 件のコメント:
コメントを投稿