Jump to page content
obsolete

Cross platform dialog adaptation

Ever since I found that I needed to cross-compile Connect-4 to Windows for version_lili, I’ve been mired in the fun that is cross-platform development. The following page demonstrates a few changes I’ve come to make (in November 2007) to some of my basic dialog boxes to improve their appearance.

REALbasic 3 had no message box facility, so I wrote my own StdDialog class to generate message box dialogs. It was complemented by a set of static calls to generate error, information, Yes/No and Yes/No/Cancel dialog boxes. For a long time, the static calls only provided “OK”, “Yes”, “No” and “Cancel” as button captions:

At some stage, I got with the program and started permitting custom button captions; I forget why I enlarged all the buttons, but it worked, even if they were now mostly too large:

Another code branch or version returned to small buttons, but now larger captions stopped fitting:

Several years later, I realised how simple it would be to dynamically measure the button caption widths and adjust the window accordingly, something I had planned to do in the past. After all, I was already calculating the text wrapping in order to determine the window height. This final version follows pretty much correct Mac practice regarding layout, although I can’t do the red tint:

The REALbasic method Graphics.DrawIcon, which draws messsage dialog icons, had no support for Mac OS X:

So, I found that it was far easier, under Mac OS X, to simply call the ShowStandardAlert Carbon function to draw the entire window, complete with the huge fancy icons:

I can get away with not being able to provide the ModalFilterUPP, simply because the system caches window content. Under Mac OS 9, ModalFilterUPP is essential. Worse, under Mac OS 9, it always tints the alert dialog red, which is not helpful.

My Windows message boxes were pretty ugly looking too, although it took me until now (2007) to realise that the button width and height, button spacing and message alignment were all wrong:

Also, if the window needed to be redrawn, the icon would routinely fail to appear:

I’ve got some perfectly working code that uses the real MessageBox call, but decided not to use it in order to keep my custom button captions (it would be a step backward to revert to Yes/No/Cancel now). My own message boxes, however, look pretty convincing now:

My About boxes, using my StdAboutDlg class, were pretty reasonable-looking in Windows and Mac OS 9, although I rewrote the class in order to be able to size the window automatically (instead of by hand) and to cure various display bugs in Windows. However, it is under Mac OS X where the design really falls short:

Therefore, I’ve adapted the code to generate a revised design under Mac OS X:

By convention, the icon should be displayed also, but the adaptation thus far was painful enough and the icon is, after all superfluous, so for now, I am not intending to figure out how to read an icon suite entry and paint it in 32-bit :)