Building PICT 1
Volume Number: 10
Issue Number: 2
Column Tag: Getting Started
Related Info: Color Quickdraw List Manager
Using The List Manager
Building & using a list of PICT Resources
By Dave Mark, MacTech Magazine Regular Contributing Author
Note: Source code files accompanying article are located on MacTech CD-ROM or
source code disks.
At the end of last month’s column, I said that this month’s column would go back
to Color Quickdraw. I lied. I was working on a program I was writing for Daniel (it
teaches little kids to read) when I got embroiled in a knotty problem involving the List
Manager. As I was wrestling with the problem, I came up with the idea for this month’s
column. I liked the program so much that, instead of waiting till next month, I decided
to go ahead and present it now. Don’t worry, we’ll get back to Color Quickdraw
eventually...
PictLister
This month’s program is called PictLister. PictLister lets you create a window
listing all the PICT resources available to your program. Note that this includes PICT
resources found in your application’s resource fork as well as those found in any
resource files opened by the System. Figure 1 shows the PICT resources found by my
copy of PictLister.
Figure 1. A PictLister window.
When you double-click on the name of a PICT resource, PictLister creates a new
window containing the PICT.
Creating the PictLister Resources
Start by creating a folder named PictLister inside your Development folder. Fire
up ResEdit and create a file named PictLister.π.rsrc inside your PictLister folder.
Now create an ALRT resource (along with a corresponding DITL resource) for our
error alert. The ALRT resource should have a Top: of 40, a Left: of 30, a Height: of
116, and a Width: of 292. Be sure to set the DITL ID: to 128.
Next, create a DITL with an id of 128. Use the specifications in Figure 2 to create
the OK button and the specifications in Figure 3 to create the error alert’s static text
item.
Figure 2. Specifications for the error alert’s OK button.
Figure 3. Specifications for the error alert’s static text item.
Next, create an MBAR resource with an id of 128. The MBAR should list three
MENU ids: 128, 129, and 130. Create three MENU resources according to the
specifications in Figure 4. Be sure to include a separator line as the third item in the
File menu.
Figure 4. The three MENU resources.
Finally, go into the scrapbook (or your favorite graphics application) and use
Copy and Paste to create a series of PICT resources in the resource file. Select Get
Resource Info from the Resource menu and give each resource a name. It’s important to
name your PICT resources, since PictLister uses the PICT’s name to represent the
PICT in a PictLister window. Figure 5 shows the Get Resource Info window for my first
PICT resource. Notice that the Purgeable check box is checked.
Figure 5. Get Resource Info for my first PICT resource.
Creating the PictLister Project
Save your changes and quit ResEdit. Launch THINK C and create a new project
named PictLister.π in the PictLister folder. Add MacTraps to the project. Next, create
a new source code window, save it as PictLister.c and add it to the project.
Type in the following source code:
/* 1 */
#define kMBARResID 128
#define kSleep 60L
#define kMoveToFront (WindowPtr)-1L
#define kNilFilterProc (ProcPtr)0L
#define kEmptyString "\p
#define kHasGoAway true