Final presentation of the day - Rob Gayvert - wxSqueak. This project combines Squeak and the wxWidget set. This is a blend of wxWidgets and Squeak - it's Open Source, and brings native widgets to Squeak. Runs on win32, OS X, and Linux/GTK. Current version: 0.4.1, using wxWidgets 2.6.1 and Squeak 3.8. Here's Rob:
So, what's the motivation? The Squeak UI is cool, but a native UI is essential for many situations. It leverages an existing library (wxWidgets) - it's already been wrapped by other languages. Also, Rob has some experience with wxWidgets. The goal is similar to the goal for Chagall (native on Pollock) - native widgets, portable image. He also wants to be as minimally invasive to Squeak as possible. Ideally, provide a VM level plugin (not quite possible). As well, preserve the API style of wxWidgets.
What is wxWidgets? Cross platform C++ toolkit (goes beyond GUI). Has bindings for multiple languages (wxPython, wxRuby, wxPerl...). It's shipping now with OS X, and has been around awhile.
Challenges? Dueling event loops (wxWidgets, Squeak). Large API (400 classes, 3000 methods). Both Squeak and wxWidgets are fast moving targets. There are a lot of constants, and some vary by platform. Needs synchronous callbacks for event handlers and virtual method overrides. One of the big jobs was a Smalltalk to C++ object mapping. Other things:
- Squeak process polls a primitive looking for wxEvents every 5 ms
- synchronous callback to squeak may happen
- win32 - need to restrict ioProcessEvents
- OS X - need to single thread the event loop
- Linux - no changes, but slow (not responsive enough)
The plugin generator is Squeak based (not SWIG). At the Smalltalk level, he's done a fair bit of work to make the API simple to use for Smalltalkers, by including a bunch ofcenverter/helper functions to deal with C++ interfacing issues. There are around 2700 constants, mostly enums. These are loaded at startup to handle platform dependencies.
The event handling for wxWidgets has to be synchronous (which is different than normal Squeak). Had to allow event stacking because of that. Required help from one of the Squeak VM guys for parts of that.
Generic callbacks: Used for C++ virtual methods that may be overridden in Squeak. There's interest in this stuff - other Squeakers are working with it and extending it. Heh - looks like they'll get UI specs - wxWidgets is going to an XML representation for that. He's hoping to have it all production ready for Squeak 4.0. Unicode and Custom controls will come along the way.