Skip to content

Commit

Permalink
#LD48 BOOYA got rid of sizeof, and used a proper closure for expose-e…
Browse files Browse the repository at this point in the history
…vent
  • Loading branch information
Amos Wenger committed Dec 17, 2011
1 parent 83e242b commit cb3e87f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
.*.swp
gtk-example
*_tmp
.libs
6 changes: 4 additions & 2 deletions cairo/Cairo.ooc
Expand Up @@ -25,9 +25,11 @@ HintStyle: cover from cairo_hint_style_t
HintMetrics: cover from cairo_hint_metrics_t
Format: cover from cairo_format_t

UserDataKey: cover from cairo_user_data_key_t* {
UserDataKeyStruct: cover from cairo_user_data_key_t { }

UserDataKey: cover from UserDataKeyStruct* {
new: static func -> This {
gc_malloc(sizeof(cairo_user_data_key_t)) as UserDataKey
gc_malloc(UserDataKeyStruct size) as UserDataKey
}
}

Expand Down
16 changes: 5 additions & 11 deletions gtk-example.ooc
Expand Up @@ -17,21 +17,15 @@ repaint: func (cr: Context) {
cr stroke()
}

onExpose: func (widget: Widget, event, userData: Pointer) -> Bool {
/* expose event is sent when the widget (or parts of it) needs to be redrawn.
we repaint everything then.
*/
cr := GdkContext new(widget getWindow())
repaint(cr)
cr destroy()
return true
}

main: func {
win := Window new("Hai.")
win setUSize(400, 200) .connect("delete_event", exit)
win setAppPaintable(true)
win connect("expose-event", onExpose as Func)
win connect("expose-event", ||
cr := GdkContext new(win getWindow())
repaint(cr)
cr destroy()
)
win showAll()

Gtk main()
Expand Down

0 comments on commit cb3e87f

Please sign in to comment.