Giving some Juce to cross-platform tools

Juce in the spotlight

More Juce in use

In addition to the source code for the core library, the demo program and a simple little "Hello World" project (designed to get you started), you also get complete source to the Juicer. This is a visual tool that enables you to lay out components on a form, establish basic size/position for each child component, set up callback routines, and so on. You can test the interface within Juicer and, once you're happy, it will spit out a C++ source file with corresponding header which can then be incorporated directly into your project. The same .CPP file can be loaded back into Juicer, provided that you retain the XML-based metadata which Juicer places within the source. This is done by enclosing the metadata inside a "#if 0" block, thereby preventing the compiler from attempting to compile it! This is obviously a lot less work than attempting to reparse the C++ code. Juicer isn't complete (for example, not every callback for every widget type is implemented), but it eliminates the need for a lot of tedious hand-coding of complex control layouts.

Before I wind up, I should also mention another cunning little innovation in the shape of Julian's freely downloadable BinaryBuilder utility. These days, applications typically need a lot of additional binary data such as image icons, sound files, and so on. The means of encoding this information into an executable is obviously platform-dependent (bundles under OS X, custom resources on Windows, etc) which isn't a great thing from a cross-platform perspective. The BinaryBuilder utility neatly gets around this by scanning a designated directory and encoding every encountered file into an unsigned character array, each of which ends up as a field inside the target class. For example, the demo program has a directory called binarydata containing a ZIP file, a PNG file, a WAV, and some other stuff. These files all end up as arrays within the BinaryData.cpp file that's generated by BinaryBuilder.

You might think this is inefficient, but I did just mention ZIP files! Along with everything else, Juce has built-in ZIP file support. Decompressing a random SVG file from a ZIP stream created via BinaryBuilder is as easy as this:

MemoryInputStream iconsFileStream (BinaryData::icons_zip, BinaryData::icons_zipSize, false); 

ZipFile icons (&iconsFileStream, false); 

// Load a random SVG file from our embedded icons.zip file.

InputStream* svgFileStream = icons.createStreamForEntry 
(Random::getSystemRandom().nextInt(icons.getNumEntries()));

if (svgFileStream != 0)
{
  Drawable* loadedSVG = Drawable::createFromImageDataStream (*svgFileStream);
  // etc...

Summary

So is Julian operating a charity here? Well, no. If you use Juce to create GPL'd open-source applications, then you pay nothing. However, if you want to create commercial applications, you'll need to pay £399+VAT for a commercial license. This entitles you to use Juce in just one product. Additional licenses cost another £399 per product, or, more sensibly, you can pay an additional £300 to upgrade to a full commercial license for the creation of an unlimited number of commercial products. This obviously compares very favourably with Qt: where a three-platform (Windows, Mac, Linux) commercial license will cost you $6600 or over £3,300.

Bottom line? I'm very impressed with Juce. Not only is it reasonably priced, full-featured, and very well thought out, but it also produces tight executables making it ideally suited not only for larger projects but small shareware utilities. Even the supplied source code is a joy to browse as Julian has used a consistent, intuitive naming style for all his classes and methods. You can download a compiled HTML (CHM) file of reference documentation from the Juce website, or browse online here.

And in Figure 3, here's Juicer running on Mac OS X with a screenshot of our "Fearless Leader" (see support forum!) How do you know it's running on the Mac? The subtle give away is the caption bar – the close/maximise/minimise buttons have moved over to the left: compare with other screenshots. ®

Shows Juicer running on Mac OS X.

Sponsored: Designing and building an open ITOA architecture