[racket] Racket/GUI
Stephen De Gabrielle <stephen.degabrielle at acm.org> writes:
> You can use the FFI to pull in more Gtk, Win32, or Cocoa widgets
> on the
> corresponding platform. The `get-handle' and `get-client-handle'
> methods of a `window<%>' provide access to the underlying GUI
> toolkit's
> object, which lets you mix `racket/gui' windows and naive widgets.
>
> I'm fascinated by this, I'm having trouble locating an example where
> it is used to bring in a native control.
The following code brings up a toggle button from GTK+.
Hope this helps. :^)
#lang racket/gui
(require ffi/unsafe)
(define gtk-toggle-button-new-with-label
(get-ffi-obj "gtk_toggle_button_new_with_label"
#f
(_fun _string -> _pointer)))
(define gtk-container-add
(get-ffi-obj "gtk_container_add"
#f
(_fun _pointer _pointer -> _void)))
(define gtk-widget-show
(get-ffi-obj "gtk_widget_show"
#f
(_fun _pointer -> _void)))
(define win (new frame% (label "hello, world")))
(define toggle (gtk-toggle-button-new-with-label "toggle me"))
(gtk-widget-show toggle)
(gtk-container-add (send win get-client-handle) toggle)
(send win show #t)