PP Modeless Child Wins
Volume Number: 12
Issue Number: 1
Column Tag: Getting Started
PowerPlant and Modeless Child Windows 
By Dave Mark, MacTech Magazine Regular Contributing Author
Note: Source code files accompanying article are located on MacTech CD-ROM orsource code disks.
In last month’s column, we built an application that featured windows with two push
buttons and a scrolling picture pane. The first button beeped when you clicked it. The
second button was disabled. This month, we’ll extend the PictScroller program. We’ll
enable the second button so that when you click it, a new window appears, allowing you
to select a new picture for the scrolling picture pane.
Thanks once again to Greg Dow for all his PowerPlant help. Greg is a real friend
to this column and has never been too busy to lend a hand.
Copy Last Month’s
PictScroller Project
Start off by making a copy of last month’s project folder. Rename it PictScroller2
or something like that. This way, if things get a little screwy, you don’t have to start
over from scratch. At the very least, you’ll be able to start from where we left off last
month.
Once your old folder is tucked safely away, open up the PictScroller2 folder.
Our first step will be to add two more PICT resources to the Constructor file PictScroller.rsrc.
• Open up PictScroller.rsrc using your favorite resource editor.
• Change the resource ID of the existing PICT resource from 128 to 2001. • Add two more PICT resources to the file and change their resource IDs to 2002 and 2003.
• Save your changes and quit your resource editor.
In addition to the sun PICT from last month’s column, I added the moon and red car pictures from my ScrapBook.
Our next step is to edit PictScroller.rsrc using Constructor.
• Double-click on the file PictScroller.rsrc.
Constructor will open the file PictScroller.rsrc and display a window listing
all the views in this file. At this point, we’ve got a single view, an LWindow with an id
of 1 and the name PictWindow. Our first goal is to make a few changes to our existing
LWindow view. Our second goal is to create a new view, an LWindow with 3 radio
buttons and a mini-PICT frame.
Let’s start by editing the existing LWindow.
• Double-click on the LWindow with the id of 1 (it should be the only view listed in
the master view list).
The view editing window for the PictScroller LWindow will appear.
• Double-click on the titlebar of the window embedded in the view editing window
(the title bar says PictScroller).
An info window for the PictScroller window will appear. This next step is
incredibly important:
• Change the Class ID field from wind to CpsW.
• Close the PictScroller info window.
The four letter (case sensitive!) code tells PowerPlant what type of object we
are creating. The code 'wind' corresponds to the class LWindow. That’s the class we
used last month. This month, we’ll be subclassing LWindow with a class named
CPictScrollerWindow. When you enter the CPictScrollerWindow class definition
(later in the column), you’ll see that we create an enum constant with the name
class_ID and the value 'CpsW'. Each time you create a class that implements a
PowerPlant view, you’ll enter the class’ class_ID code in the Class ID field in the
view’s info window.
• Double-click on the LPicture pane (it has a pane id of 1003).
• When the pane info window appears, change the PICT Resource ID to 2001. The first of your three PICT resources (the one with the resource ID 2001) should now be displayed in the scrolling pane.
• Close the LPicture pane info window.
• Double-click the Dialog button (the right button). • Click on the Enabled check box (so that it is checked).
• Change the Value Message to 1001.
• Change the Button Title to Picture...
• Close the button’s pane info window.
The button will now say Picture... and will no longer be disabled. Also, when it
is clicked in your application, it will broadcast a message with a value of 1001 to any
listeners.
Now let’s add a new view.
• Close the view editing window for the PictWindow LWindow.
• Select New Resource from the Edit menu. • When the view naming dialog appears, make sure LWindow is selected from the
popup menu, type Pict Selector (Child) in the edit field, and click the OK
button.
A new view editing window will appear. Before we add any items to the new view,
change the view’s ID to 2000.
• Close the view editing window.
• Select LWindow 128 in the master view list, then select Resource Info from
• Change the Resource ID from 128 to 2000.
• Close the resource info window.
• Double-click on the Pict Selector view in the master view list.
A view editing window for view 2000 will appear.
Note: Greg Dow uses a numbering convention that I’ll try to stick to from now on. He numbers all his new views by thousands. So his views have IDs like 1000, 2000,
3000, etc. The items within a view start at one plus the view ID. That means that the
items in this new view will be numbered 2001, 2002, 2003, etc. If you have groups
of items (like radio buttons, for example), you might want to leave holes in your
numbering scheme. For example, you might number your radio buttons 2001, 2002,
and 2003, then start the next set of items with 2010, 2011, 2012. As always, pick a
scheme you like and try to be consistent.
• Double-click on the window inside the view editing window.
• When the info window appears, change its settings to match those shown in Figure
1.
• Close the info window.
Figure 1. The info window for the Picture Selector window.
Next, you’ll create the four items that make up this new view: three radio
buttons and a mini-picture frame.
• Drag an LStdRadioButton from the palette window onto the Picture Selector
window.
• Double-click the new radio button.
• When the info window appears, change its settings to match those shown in Figure
2.
• Close the info window.
Figure 2. The info window for the Sun radio button.
• Drag a second LStdRadioButton from the palette window onto the Picture Selector
window.
• Double-click the new radio button.
• When the info window appears, change its settings to match those shown in Figure
3.
• Close the info window.
Figure 3. The info window for the Moon radio button.
• Drag a third LStdRadioButton from the palette window onto the Picture Selector
window.
• Double-click the new radio button.