September 93 - Classy
William L. Colsher
Classy was recently purchased by Symantec and has been taken off the market. They have said that they will be rereleasing it at some point in the future, perhaps synchronized with other product releases. With the current Bedrock effort, and rumors of a Symantec C++ for Windows and a revised Think Class Library, there are a variety of scenarios one can imagine. Regardless, this article is probably a first in the history of computer journalism–a review of a "finished" product that has not yet been released. We thought you might enjoy it if for no other reason than to get a glimpse of what Symantec might have up its sleeve.
Classy is an object programming utility for use with Think C++ 6.0. It consists of a MacDraw-like view editor with an integrated code generator and a set of classes that implement view resources, stream I/O, and a variety of other useful extensions to the Think Class Library.
The Classy System
Like most programmers, I have a tendency to drag new applications to my drive and double click. Classy slowed me down a bit, since it comes as a CompactorPro archive. While Classy extracted itself (to a total of about 2MB), I read the installation chapter of the manual (Chapter 13-I guess these guys know programmers.) I found the installation process a bit confusing. I suspect this was mostly me-most of my work is with MPW (though that could change with Symantec C++ and Classy on my drive.) Post-extraction installation consists of dragging a couple of folders to the "Symantec C++ for Macintosh" folder (this is where I got confused-I had forgotten about THINK's approach to directories) and then running a program called "GENERALizer." That utility installs the Classy updates to the Think Class Library. Finally, a printed release note documents a couple of bug patches you must manually apply to the Symantec OOPS library.
Once installed, Classy's 24 classes are at your service (see Classy Classes on the next page). They can be used in an existing application just like any of the TCL classes. The best way to use the new classes is to fire up the Classy view editor (also named Classy) and build an application. But first, let's take a look at a few of the key classes.
Of the 24 Classy classes most are user interface items that either enhance or replace TCL equivalents. However several are particularly worthy of note. First among these are the stream I/O classes. In order of inheritance they are:
These classes provide the infrastructure necessary to implement Classy's object I/O system. Get and Put functions are provided for all the "standard" data types (like PutChar(), PutBoolean(), and so on) as well as handles and pointers. In addition, there are GetObject and PutObject member functions that operate on CObject and its descendants.
The real power of the stream extensions comes from a pair of new virtual member functions Classy adds to CObject: PutTo and GetFrom. As you might expect, these two functions form the basis of a system that greatly simplifies manipulating your document's data.
To make that job even easier, Classy has added CSaver, a subclass of TCL's CDocument. CSaver implements the all the basic document I/O functions (like OpenFile and DoSave) using CFileStream. It knows what to read or write by adding a new data member called "itsContents." This data member is a pointer to the document's contents. Obviously, most applications will have more than a single data object in their document. The trick is to define a root object with PutTo and GetFrom member functions that deal with the "real" data objects correctly. If you then define a correct PutTo and GetFrom for each of your data objects everything else will be automatic. If this sounds a little confusing, don't worry: the Classy manual is pretty good on this point.
There is a great deal more to creating a complete application and document, but I know that what you really want to hear about is the view editor.
Using the Classy View Editor
The first step in using the Classy view editor is to make a copy of the Classy "starter" project and resource file. As with TCL, the starter project is already set up with the "basic" segments you need. The ".rsrc" file is particularly interesting because it is actually the Classy program's "document." As such, it displays the Classy document icon rather than the familiar jack-in-a-box. You can still use it for your own resources of course, but double-click and you're into Classy, designing your application.
Before leaping into the view editor, you need to tell Classy a little bit about the application you intend to write. By selecting the "Application…" item in the Edit menu you can give Classy the information it will need to generate code for you. This information includes an application ID that is used to generate unique identifiers, a copyright message that will be placed in each source file, and your application's signature and file types (the ones you faithfully registered with Apple using the "C/F Registration Requests" stack).
The first step of course is to create a new view. For those of us used to MacApp terminology, a Classy view is most often a window of some kind and what we would call subviews are called "panes." (This corresponds to the TCL class terminology.) All the window types you would expect are available including Alert, Dialog, Floating Window, and Tearoff Menus. Classy's tearoff menus are so easy to use I put two of 'em in my test application.
One special window is the "Main Window." In TCL, documents are associated with a single main window (rather than a list of windows as in MacApp). Classy makes this connection for you when you select "Main Window" as the type of window. When creating your main window you do need to be careful not to make the name too long. Classy will generate class names from what you enter and file names that are even longer. When the Symantec C++ compiler gets hold of those names and adds ".XSYM" you can end up over the 31 character limit (yes, it happened to me).
Once a particular window type is selected, its attributes can be edited by selecting the View Info menu item (see Figure 1-Main Window View Info). As you can see from the illustration, you can do quite a bit of customization. There are additional "info windows" for alerts and floating windows as well.
Panes in the view
Classy's view editor takes a MacDraw like approach (see Figure 2-Editing in Classy). To add a pane to your view just click on a tool and then click where you want the item to appear. Hold down the mouse button and you can size the pane. A pane can be resized later by selecting it and dragging its resize handle or by entering exact sizes in its data member's dialog. Multiple panes can be selected and dragged as a group. There are also some very nice alignment tools that manipulate groups of items. Most of the pane attributes (such as font and alignment) can be applied singly or to groups.
The tools in the floating palette are almost all self explanatory. A few are less than obvious however: the "Warning Icon" produces an icon button and the shadowed version yields a nifty multi-state button. The "thing" that holds an overlapping ellipse and square yields a picture button and its shadowed twin a multi-state version of the same. Multi-state buttons can have different graphics for on/off and hilight states).
Of course, virtually every object placed in a view will need a bit of tweaking before it's just right. Classy provides an interface to the data members of each pane that is similar to that used in Apple's ViewEdit (see Figure 3-Editing Data Members). When you need to go further, the Classes… menu item provides a dialog that gives you the ability to define new subclasses of existing classes. You can even define new data members for the class, and Classy will automatically generate the appropriate stream I/O calls so that your new classes will instantiate fully with no additional intervention on your part.
Commands and Menus
As you might expect, Classy provides a nice editing dialog for commands (see Figure 4-Editing Commands). In the illustration I've created a new command constant "cmdSpeak-Phonemes." Classy automatically gave it a number (that I can change if necessary). I've chosen the class CPronunciation_Dict to handle the command and selected "Call" as the action. When the time comes to generate code Classy will insert a "case cmdSpeakPhonemes:" in the switch in x_CPronunciation_ Dict.cp's DoCommand() method. It will also create an empty method called DoCmdSpeakPhonemes() that I will later override in CPronunciation_Dict.cp to do what it needs to do. I'll discuss the way Classy generates code and file names later.
Menus are created and edited in a two layered process (see Figure 6-Editing Menus). First you select a menu to edit (back window) and then click the "Edit Menu Items" button (hidden in the illustration). The subsequent "Menu Edit" dialog provides all the tools necessary to make your menus look and perform as you want them to. Recall that when you create a command you specify the class that will handle it. When you create a menu item and specify its command you're all done. The connection has been made and there's an empty method waiting to be implemented. Buttons have commands associated with them in the same way.
When the time comes to generate code, Classy uses a set of templates (which you can edit) to generate pairs of ".cp" and ".h" files for each class you created. One set of files is prefixed with "x_." These files contain the code that Classy controls and will modify when you make changes in the view editor. The classes in these files are also prefixed with "x_." The second set of files contain the skeleton code that you will modify. The classes in these files have the names you would expect and are sub-classed from the corresponding "x_" classes.
This two layer approach means that both you and Classy are free to make changes at will and can do so without treading on each other's territory. This flexibility costs almost nothing at run time, and since it is administered by Classy there is virtually no "mind share" involved either.
After the code is generated you add it to your Think project in the usual way. The starter project comes with a "place holder" segment already set up for you. When the compiler finishes its job you'll have a complete working skeleton of your application. For what it's worth, the program I developed to test Classy took about two hours from the time I sat down to the first running prototype. That includes the interface, two tear-off menu palettes which worked perfectly from the start, and a few additional windows. Pretty darn productive if you ask me.
Stylistically, Classy's code is very similar to TCL. A big comment block containing a description of the class and copyright information (with your name) heads up each file. Additional comment blocks describing their use separate each method and two or three line comments regarding implementation act as place holders in empty methods. Although I have only a passing familiarity with TCL, I found Classy's code easy to understand and modify.
Classy is one of the great bargains among Macintosh development tools. Object Factory has done a tremendous job in every area from Object I/O, to TCL bug fixes, to the fastest view editor I've ever seen.
As you can probably tell, I really like Classy. Nevertheless, it is not completely without flaws (but hey, it's only version 1.06!). I came across a couple of small bugs, neither of which affected my project or the generated code in any way. The documentation, while adequate, has a lot of room for improvement. It is particularly frustrating for a new user to search through the program's menus for things that aren't there anymore or have changed name or location. Finally, Classy's user interface could use a bit of tuning up. I already mentioned that I was allowed to enter class names that would eventually result in illegal file names. And my favorite annoyance was the need to hit Cmd-L to edit a pane's data members. A simple double-click like everybody else uses would be nice.
In spite of a number of very minor flaws, Classy is an eminently usable, utterly indispensable tool for anyone who uses TCL. It is highly recommended.