My continuing adventures with composite windows, listboxes, toolbars, and HTMLViewers
I am a happy user of Electric Butterfly’s MaxiToolbarPro. I use it because it makes it so easy to maintain a nice set of cross-platform toolbars, and they look native enough for me on OS X.
And then REALbasic 2005 shipped, with a feature I’ve been waiting for: the HTMLViewer. The HTMLViewer is a platform-native control for rendering HTML. On OS X, it uses WebKit, the rendering engine behind Safari. On Windows, it uses IE. On Linux, it uses Mozilla if available. But I don’t plan to ship a Linux version of Tangelo anyway.
But this great feature comes with a price: on OS X, it can only be used with composite windows. I didn’t think that would be a problem. Of course, I hadn’t used composite windows before, but I didn’t see why it should cause any trouble.
Then the trouble started.
My toolbar buttons would randomly disappear or draw incorrectly. I spent a few weeks going back and forth with Dave from Electric Butterfly, and in the end, we determined that it was a bug in REALbasic itself, that only occurs when using a custom canvas on a composite window with a listbox. Which describes my interface pretty well, actually. Dave was incredibly helpful, but since the bug is in RB, there wasn’t anything more he could do.
I finally decided that instead of waiting for RB to fix the bugs with listboxes on composite windows screwing with the toolbars, that I’d just go ahead and use native toolbars on that window (REALbasic has support for native OS X toolbars, but they’re not cross-platform, of course). No harm done, just a little extra code to shift things around a bit. So I add native toolbar buttons to the window and write a bunch of conditional code to put things in the right places depending on the platform (because Windows is fine, and I can still use MaxiToolbarPro without a hitch). Now it crashes on quit. Every time.
So I narrow it down and discover a conflict between RB’s native toolbar support and the HTMLViewer. Grrr. I filed a bug report and tried to drum up some support on the NUG, but no bites. So start thinking and I remember Thom McGrath wrote some wrapper code for using “real” toolbars, not just the partial RS implementation. I download it, start to add it to my project. Now it won’t compile. Thom’s classes require the app to be Mach-O, one of two executable formats available for Mac OS X (the other being PEF). OK, so I compile it as Mach-O and now it crashes on startup. SQLitePluginPro error. I confirm the bug with Will from SQLabs, but there’s no fix yet. Crap! Well, I’ll just switch to using REALSQLDatabase, the new database engine in RB 2005, since that’s based on SQLite, right? Wrong! REALSQLDatabase is SQLite 3, but SQLitePluginPro is SQLite 2. And they’re not compatible. And there’s no way to migrate without the SQLitePluginPro working. More thinking.
I end up downgrading SQLitePluginPro to 1.1 or something like that, and it starts working on Mach-O. Cool. Finally some progress. But now I hit another problem: using Thom’s HIToolbar classes, I can apply stock Apple icons to my toolbar buttons, but no custom icons. Well, that sucks. So I go back and forth with Thom a bit, and in doing so, I find that it works with RB 5.5.x, which, of course, does me no good since the whole point was to use the HTMLViewer in the first place! After a bit, Thom tells me that RB2005, all of his declares to Quartz need to be declared to Carbon instead. So I change about four or five methods making those declares, and after only three weeks, my window works now!
So, long story short, expect a new Tangelo beta real soon now.