TweetFollow Us on Twitter

TCL and VA
Volume Number:11
Issue Number:10
Column Tag:Getting Started

TCL and Visual Architect, Part 1

By Dave Mark, MacTech Magazine Regular Contributing Author

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.

Last month we took a first look at PowerPlant and Constructor, the class library and interface construction tool that comes with every copy of CodeWarrior from Metrowerks. This month, we’ll cross the aisle and take a look at Symantec’s counterparts, the Think Class Library (better known as the TCL) and Visual Architect (VA).

About Symantec C++
for Macintosh

When you buy CodeWarrior, you get a PowerPC compiler and a separate 68K compiler. Version 8.0 of Symantec C++ takes a slightly different approach. Version 8.0 comes with a complete rewrite of the THINK Project Manager, known as the Symantec Project Manager (SPM). Though the SPM can run on both 68K and PowerPC platforms, it is currently only capable of generating PowerPC native code. To generate 68K code, you’ll need to use version 7.0.4 of the THINK Project Manager (TPM) (it’s installed in the same tree as SPM, automatically, when you install SC++ 8.0). The 8.0 CD includes both SPM and TPM. According to Chris Prinos (a Symantec engineer and one heckuva nice guy), both of these environments are source code compatible. In other words, you can maintain a single source code base and compile it with 7.0.4 if you want 68K code and 8.0 to generate PowerPC code. I haven’t tested this theory yet, and I’d like to get feedback from you about compiling across environments.

The SC++ User’s Guide that comes with 8.0 includes some tutorials showing you how to create a user interface using Visual Architect and how to implement that interface using the TCL. One of the tutorials (User’s Guide, Chapter 14) is very similar to the PowerPlant example we went through last month and is perfect for this month’s column.

If you have a copy of the User’s Guide, you’ll see that I’ve split the Chapter 14 tutorial into two parts. This month, we’ll get to know Visual Architect and use it to create a basic TCL project. Sorry to split the column in two, but there just isn’t enough space to do the whole thing in one swell foop.

Create A New Project

In last month’s column, we created our PowerPlant project by duplicating an existing project. We could have taken advantage of PowerPlant’s canned project models to create the new project instead. That’s the exact approach we’ll use to create our new TCL project.

• Create a new folder (anywhere outside the Symantec C++ for Power Mac folder) named Button ƒ.

• Go into the Symantec C++ for Power Mac folder and double-click on the Symantec Project Manager application. If you don’t have access to a PowerMac, use the THINK Project Manager instead and follow along as best you can (Either way, you will be using the same version of Visual Architect).

The Symantec Project Manager (also known as SPM) will prompt you for the name of a file to open.

• Click on the New Project button.

SPM will prompt you to name your new project and to select the project model that will be used to produce the project.

• Type in the name Button.Π and select VA Application from the popup menu, then click the Save button.

The Button.Π project window will appear (See Figure 1). The file Project Resources.rsrc contains the basic set of resources used for a TCL application. Once you get through this column and get your program working, take some time to explore the resources that come with the generic VA project. For now, we’ll just use the resources we’ve got.

Figure 1. The Button.Π project window.

Here’s a quick tour of the project window. The Headers popup presents you with a list of all the header files accessed by your project. A file’s headers are not added to the list until the file is compiled. If you control-click on the popul, the list will also include the headers from any precompiled headers used by the project.

The second popup, labeled Options, lets you apply different sets of preferences to your project. To build a custom options set, select Options... from the Project menu. Make changes to the various option panes, then select Save Options As... from the Options: popup menu to give your current settings a name. This new set is now available from the Options popup in the project window. While it is nice to be able to switch between options within a project, it sure would be nice to be able to create a master set of options for all projects, or to create several sets and export them to other projects. Maybe in 8.0.4? By the way, all the options are recordable, so you can create a script to set up a project’s options.

If you click on one of the four column headers, a small down-arrow will appear to the left of the column label. Once the arrow is in place, click on it again to change the sorting order of the project files. For example, clicking on the word Code lets you order the files by object code size, switching between low to high or between high to low.

The check-mark column corresponds to CodeWarrior’s “touch” popup menu. It lets you mark a file as either needing to be compiled or (assuming it was compiled at some point) as already compiled. If you upgrade to 8.0.3, the Make status is shows for groups as well as for individual files.


The file Visual Architect.rsrc contains special resources used by Visual Architect to define your program’s views and panes within views. Though you can browse this file using your favorite resource editor, there is really no reason. Leave this resource file to Visual Architect!

The group of files labeled Runtime Libraries contains the support libraries SPM needs to build your application. The group labeled THINK Class Library contains the source code that implements all of the TCL classes. In last month’s program, we added the PowerPlant classes we needed to our project as we identified them. The “VA Application” project model adds a complete set of TCL files to the project. Open the THINK Class Library group (click on the triangle to the left of the group) and look through the TCL files. The up side to this approach is that you’ll never have to search for the TCL classes you’ll need. They’ll already be part of your project. The down side of this strategy is that the project file will have a base size (when compiled) of about 10 megs (yikes!). Of course, if you’ve got a gigabyte hard drive, 10 megs isn’t that much space. With the objects removed, your project folder will weigh in at about 165K.

Using the shared library project model saves space because the TCL portion is a separate sub-project that gets shared among all the projects that use it. You still retail full debugging capabilities, and both the TCL project and your application project can be open at the same time (the SPM allows you to have any number of projects open, unlike the TPM or Code Warrior).

Opening Visual Architect

At this point, your project lacks a core, that is, the set of functions (like main()) that drive your application. The source code files containing these functions will be generated by Visual Architect once you define your user interface. That’s exactly what you’ll do now.

Figure 2. The main VA window showing the views in Visual Architect.rsrc.

• In the Button.Π project window, double-click on the file named Visual Architect.rsrc.

SPM will launch Visual Architect, opening the copy of Visual Architect.rsrc in the folder Beeper ƒ. The window that appears (Figure 2) lists the views defined in this file. By default, the file comes with a single view named Main.

• Double-click on the word Main in the view window.

A window will appear showing the panes in the view named Main.

• Select Show Item Numbers from the Options menu.

Item numbers will appear next to each of the two window panes (Figure 3). The Main view features a PICT pane (1) and a static text pane (2). Think of the view as some type of window and the list of panes as an item list just like the DITL in a dialog.

Figure 3. The Main view, showing each of the two panes.
Item numbers are turned on.

If you double-click on a pane (or single-click on a pane and select Pane Info... from the Pane menu) a pane browsing window will appear. Figure 4 shows the pane browser for the static text pane. The browser lets you specify a name for the pane, as well as its boundaries (you can also set the boundaries by dragging the panes handle in the view window). The bottom half of the browser lists the pane’s class, as well as each of the classes that class is derived from. Clicking on the triangle to the left of a class name gives you access to that classes’ data members. If you’ve ever used the TCL before, the data members will probably look familiar to you.

Figure 4. The browser for the static text pane.

• Change the hText field in the CEditText class to something like
“Semper Fi”.

• Select Try Out from the View menu.

A window will appear emulating the current view (in this case, Main). Play with the window. Resize it. Scroll it. Drag it around the screen. When you are done, just click the close box and it will go away.

Our next step is to build an application based on the Main view. We’ll ask Visual Architect to generate the source code that implements this view and to add that code to our project.

• Select Generate All... from the Symantec Project Manager menu. The SPM menu is the diamond-shaped menu (square if you are using THINK Project Manager) immediately to the right of the Windows menu.

If the Generate All... item is disabled, try closing the front-most window. The item is disabled if the front-most window is a pane info window.

• When prompted to save your changes, click the OK button.

Once you click OK, a fancy color cursor will appear and Visual Architect will go to town, generating all the code your project needs to implement the Main view. Let’s take the view for a spin.

Back in the Symantec Project Manager

Switch back to the Symantec Project Manager and take another look at the project window. Notice that a new group, named Source, has been added to the project.

• Click on the triangle to the left of the group Source.

Figure 5 shows the new, updated project window. Seven new files have been added to the project. Two of these, x_CApp.cp and x_CMain.cp, are off limits to you. Don’t mess with these files (feel free to look them over - just don’t change anything). If you go back into Visual Architect and make changes to Visual Architect.rsrc, then select Generate from the SPM menu, VA will generate new versions of these x_ files. As you’ll see, the x_ files contain member functions that you’ll override in the non-x_ files. For example, the file x_CMain.cp contains the source code that implements the Main view. The file CMain.cp contains member functions that override the member functions in x_CMain.cp. Make your changes to CMain.cp. Leave x_CMain.cp alone.

Symantec calls these x_ files “lower layer” files and the non x_ files “upper layer” files.

Figure 5. The Button.Π project window with the new source code added.

As you add more views to your VA file, VA will generate a pair of .cp files for each new view. If you add a view called ButtonDialog, VA will generate the files CButtonDialog.cp and x_CButtonDialog.cp.

The file CSaver_CMain.cpp was generated because the useFile checkbox in the view info window for Main was checked. Checking this checkbox tells VA that a file is to be associated with this view. The class CSaver_CMain contains the functions that save and restore this file.

The file main.cp contains the project’s main() function.

• Select Run from the Project menu.

If the item reads Run With Debugger instead of Run, press the option-key while the Project menu is still down and the item name will change to Run. This is cool to watch.

The file References.cp forces references to all the TCL classes and keeps the linker from linking out classes that are not referenced in the code, but are instantiated at run time. For example, there is a function called new_by_name() that takes, as a parameter, a class name embedded in a quoted string. Since the compiler doesn’t recognize the class name (since it’s represented as a string instead of an identifier), it doesn’t reference the class and the linker might link that class out. Visual Architect uses new_by_name_() to turn its resources into objects at run time. The set of classes Visual Architect uses to represent views and panes, therefore, must not be linked out. That’s why they are all listed in References.cp. Basically, leave this file alone, unless you need to add your own classes to it. We’ll do that in a future issue.

If you get an “Out of Memory” error, you may not have enough RAM on your machine. Try quitting all your open apps, including Visual Architect and SPM, then relaunch SPM and try again. If that doesn’t work, pick up a copy of RAM Doubler. (Get the special Symantec Debugger-friendly version of 1.5.2. You can download the patch anywhere RAM Doubler is supported.)

You may also run out of room on your hard drive, since the project will take up about 10 megs of space and the application another meg. If you are worried about space, stop the compile by typing command-period and start deleting.

Once SPM starts to compile your project, go get a Fresca, take a shower, read your email, whatever. Even on a PowerMac 8100, this will take a while. SPM will compile all the new source code, along with all of the TCL. There should be approximately 157 files to update. Once everything compiles, SPM will create an application (called Button.Π.pef) and run it. A window will appear that displays the Main view. Play with the window. Resize it, scroll it, and close it if you like. Select New from the File menu to create additional Main view windows.

Till Next Month...

In next month’s column, we’ll go back to Visual Architect and add a second view to our project. This view will consist of a dialog box with an editable text field and a few buttons. We’ll also add a button to the Main view that will bring up the ButtonDialog view. Finally, we’ll ask Visual Architect to regenerate the source code, then go back into the Symantec Project Manager, and modify the source code to account for the changes we made in VA.

In the meantime, you may want to check your neighborhood bookstore for a book called Mastering the THINK Class Library by Richard Parker. The book just came out, and really does a great job of presenting the TCL from stem to stern. Way to go, Rich!

See you next month...

 
AAPL
$99.76
Apple Inc.
+2.09
MSFT
$44.08
Microsoft Corpora
+0.45
GOOG
$520.84
Google Inc.
+9.67

MacTech Search:
Community Search:

Software Updates via MacUpdate

RestoreMeNot 2.0.3 - Disable window rest...
RestoreMeNot provides a simple way to disable the window restoration for individual applications so that you can fine-tune this behavior to suit your needs. Please note that RestoreMeNot is designed... Read more
Macgo Blu-ray Player 2.10.9.1750 - Blu-r...
Macgo Mac Blu-ray Player can bring you the most unforgettable Blu-ray experience on your Mac. Overview Macgo Mac Blu-ray Player can satisfy just about every need you could possibly have in a Blu-ray... Read more
Apple iOS 8.1 - The latest version of Ap...
The latest version of iOS can be downloaded through iTunes. Apple iOS 8 comes with big updates to apps you use every day, like Messages and Photos. A whole new way to share content with your family.... Read more
TechTool Pro 7.0.5 - Hard drive and syst...
TechTool Pro is now 7, and this is the most advanced version of the acclaimed Macintosh troubleshooting utility created in its 20-year history. Micromat has redeveloped TechTool Pro 7 to be fully 64... Read more
PDFKey Pro 4.0.2 - Edit and print passwo...
PDFKey Pro can unlock PDF documents protected for printing and copying when you've forgotten your password. It can now also protect your PDF files with a password to prevent unauthorized access and/... Read more
Yasu 2.9.1 - System maintenance app; per...
Yasu was originally created with System Administrators who service large groups of workstations in mind, Yasu (Yet Another System Utility) was made to do a specific group of maintenance tasks... Read more
Hazel 3.3 - Create rules for organizing...
Hazel is your personal housekeeper, organizing and cleaning folders based on rules you define. Hazel can also manage your trash and uninstall your applications. Organize your files using a... Read more
Autopano Giga 3.7 - Stitch multiple imag...
Autopano Giga allows you to stitch 2, 20, or 2,000 images. Version 3.0 integrates impressive new features that will definitely make you adopt Autopano Pro or Autopano Giga: Choose between 9... Read more
MenuMeters 1.8 - CPU, memory, disk, and...
MenuMeters is a set of CPU, memory, disk, and network monitoring tools for Mac OS X. Although there are numerous other programs which do the same thing, none had quite the feature set I was looking... Read more
Coda 2.5 - One-window Web development su...
Coda is a powerful Web editor that puts everything in one place. An editor. Terminal. CSS. Files. With Coda 2, we went beyond expectations. With loads of new, much-requested features, a few... Read more

Latest Forum Discussions

See All

This Week at 148Apps: October 13-17, 201...
Expert App Reviewers   So little time and so very many apps. What’s a poor iPhone/iPad lover to do? Fortunately, 148Apps is here to give you the rundown on the latest and greatest releases. And we even have a tremendous back catalog of reviews; just... | Read more »
Angry Birds Transformers Review
Angry Birds Transformers Review By Jennifer Allen on October 20th, 2014 Our Rating: :: TRANSFORMED BIRDSUniversal App - Designed for iPhone and iPad Transformed in a way you wouldn’t expect, Angry Birds Transformers is a quite... | Read more »
GAMEVIL Announces the Upcoming Launch of...
GAMEVIL Announces the Upcoming Launch of Mark of the Dragon Posted by Jessica Fisher on October 20th, 2014 [ permalink ] Mark of the Dragon, by GAMEVIL, put | Read more »
Interview With the Angry Birds Transform...
Angry Birds Transformers recently transformed and rolled out worldwide. This run-and-gun title is a hit with young Transformers fans, but the ample references to classic Transformers fandom has also earned it a place in the hearts of long-time... | Read more »
Find Free Food on Campus with Ypay
Find Free Food on Campus with Ypay Posted by Jessica Fisher on October 20th, 2014 [ permalink ] iPhone App - Designed for the iPhone, compatible with the iPad | Read more »
Strung Along Review
Strung Along Review By Jordan Minor on October 20th, 2014 Our Rating: :: GOT NO STRINGSUniversal App - Designed for iPhone and iPad A cool gimmick and a great art style keep Strung Along from completely falling apart.   | Read more »
P2P file transferring app Send Anywhere...
File sharing services like Dropbox have security issues. Email attachments can be problematic when it comes to sharing large files. USB dongles don’t fit into your phone. Send Anywhere, a peer-to-peer file transferring application, solves all of... | Read more »
Zero Age Review
Zero Age Review By Jordan Minor on October 20th, 2014 Our Rating: :: MORE THAN ZEROiPad Only App - Designed for the iPad With its mind-bending puzzles and spellbinding visuals, Zero Age has it all.   | Read more »
Hay Ewe Review
Hay Ewe Review By Campbell Bird on October 20th, 2014 Our Rating: :: SAVE YOUR SHEEPLEUniversal App - Designed for iPhone and iPad Pave the way for your flock in this line drawing puzzle game from the creators of Worms.   | Read more »
My Very Hungry Caterpillar (Education)
My Very Hungry Caterpillar 1.0.0 Device: iOS Universal Category: Education Price: $3.99, Version: 1.0.0 (iTunes) Description: Care for your very own Very Hungry Caterpillar! My Very Hungry Caterpillar will captivate you as he crawls... | Read more »

Price Scanner via MacPrices.net

2013 15-inch 2.0GHz Retina MacBook Pro availa...
B&H Photo has leftover previous-generation 15″ 2.0GHz Retina MacBook Pros now available for $1599 including free shipping plus NY sales tax only. Their price is $400 off original MSRP. B&H... Read more
Updated iPad Prices
We’ve updated our iPad Air Price Tracker and our iPad mini Price Tracker with the latest information on prices and availability from Apple and other resellers, including the new iPad Air 2 and the... Read more
Apple Pay Available to Millions of Visa Cardh...
Visa Inc. brings secure, convenient payments to iPad Air 2 and iPad mini 3as well as iPhone 6 and 6 Plus. Starting October 20th, eligible Visa cardholders in the U.S. will be able to use Apple Pay,... Read more
Textkraft Pocket – the missing TextEdit for i...
infovole GmbH has announced the release and immediate availability of Textkraft Pocket 1.0, a professional text editor and note taking app for Apple’s iPhone. In March 2014 rumors were all about... Read more
C Spire to offer iPad Air 2 and iPad mini 3,...
C Spire on Friday announced that it will offer iPad Air 2 and iPad mini 3, both with Wi-Fi + Cellular, on its 4G+ LTE network in the coming weeks. C Spire will offer the new iPads with a range of... Read more
Belkin Announces Full Line of Keyboards and C...
Belkin International has unveiled a new lineup of keyboard cases and accessories for Apple’s newest iPads, featuring three QODE keyboards and a collection of thin, lightweight folios for both the... Read more
Verizon offers new iPad Air 2 preorders for $...
Verizon Wireless is accepting preorders for the new iPad Air 2, cellular models, for $100 off MSRP with a 2-year service agreement: - 16GB iPad Air 2 WiFi + Cellular: $529.99 - 64GB iPad Air 2 WiFi... Read more
Price drops on refurbished Mac minis, now ava...
The Apple Store has dropped prices on Apple Certified Refurbished previous-generation Mac minis, with models now available starting at $419. Apple’s one-year warranty is included with each mini, and... Read more
Apple refurbished 2014 MacBook Airs available...
The Apple Store has Apple Certified Refurbished 2014 MacBook Airs available for up to $180 off the cost of new models. An Apple one-year warranty is included with each MacBook, and shipping is free.... Read more
Refurbished 2013 MacBook Pros available for u...
The Apple Store has Apple Certified Refurbished 13″ and 15″ MacBook Pros available starting at $929. Apple’s one-year warranty is standard, and shipping is free: - 13″ 2.5GHz MacBook Pros (4GB RAM/... Read more

Jobs Board

Project Manager / Business Analyst, WW *Appl...
…a senior project manager / business analyst to work within our Worldwide Apple Fulfillment Operations and the Business Process Re-engineering team. This role will work Read more
*Apple* Retail - Multiple Positions (US) - A...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
Position Opening at *Apple* - Apple (United...
…customers purchase our products, you're the one who helps them get more out of their new Apple technology. Your day in the Apple Store is filled with a range of Read more
Position Opening at *Apple* - Apple (United...
**Job Summary** At the Apple Store, you connect business professionals and entrepreneurs with the tools they need in order to put Apple solutions to work in their Read more
Position Opening at *Apple* - Apple (United...
**Job Summary** The Apple Store is a retail environment like no other - uniquely focused on delivering amazing customer experiences. As an Expert, you introduce people Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.